Do not access DB when it is in maintenance mode.

If the database is in maintenace mode do not attempt to access
it.

Depends-On: I5d8ed7d3935db5568c50f8d585e37a4d0cc6914f
Change-Id: I9550452e78608589592265fca9549a51c88d65bc
This commit is contained in:
Liam Young 2020-01-30 12:38:03 +00:00
parent 9d60f159e7
commit 3cdd235144
2 changed files with 7 additions and 0 deletions

View File

@ -106,6 +106,7 @@ from charmhelpers.contrib.openstack.utils import (
series_upgrade_complete,
CompareOpenStackReleases,
is_db_initialised,
is_db_maintenance_mode,
)
from charmhelpers.contrib.storage.linux.ceph import (
send_request_if_needed,
@ -192,6 +193,9 @@ def db_joined():
@hooks.hook('shared-db-relation-changed')
@restart_on_change(restart_map())
def db_changed():
if is_db_maintenance_mode():
juju_log('Database maintenance mode, aborting hook.')
return
release = os_release('glance-common')
cmp_release = CompareOpenStackReleases(release)

View File

@ -106,6 +106,7 @@ TO_PATCH = [
'sync_db_with_multi_ipv6_addresses',
'delete_keyring',
'get_relation_ip',
'is_db_maintenance_mode',
]
@ -151,6 +152,7 @@ class GlanceRelationTests(CharmTestCase):
@patch.object(relations, 'CONFIGS')
def test_db_changed_missing_relation_data(self, configs):
self.is_db_maintenance_mode.return_value = False
self.is_db_initialised.return_value = False
configs.complete_contexts = MagicMock()
configs.complete_contexts.return_value = []
@ -161,6 +163,7 @@ class GlanceRelationTests(CharmTestCase):
def _shared_db_test(self, configs, unit_name,
allowed_units='glance/0 glance/3'):
self.is_db_maintenance_mode.return_value = False
self.relation_get.return_value = allowed_units
self.local_unit.return_value = unit_name
configs.complete_contexts = MagicMock()