Do not access DB when it is in maintenance mode.
If the database is in maintenace mode do not attempt to access it. Change-Id: I42cc19aedff2bc060343f4431c1b4834f9389f03 Depends-On: I5d8ed7d3935db5568c50f8d585e37a4d0cc6914f
This commit is contained in:
parent
1b978ffd78
commit
6fafb5abc5
|
@ -66,6 +66,7 @@ from charmhelpers.contrib.openstack.utils import (
|
|||
CompareOpenStackReleases,
|
||||
series_upgrade_prepare,
|
||||
series_upgrade_complete,
|
||||
is_db_maintenance_mode,
|
||||
)
|
||||
|
||||
from neutron_api_utils import (
|
||||
|
@ -406,6 +407,9 @@ def db_joined():
|
|||
@hooks.hook('shared-db-relation-changed')
|
||||
@restart_on_change(restart_map())
|
||||
def db_changed():
|
||||
if is_db_maintenance_mode():
|
||||
log('Database maintenance mode, aborting hook.', level=DEBUG)
|
||||
return
|
||||
if 'shared-db' not in CONFIGS.complete_contexts():
|
||||
log('shared-db relation incomplete. Peer not ready?')
|
||||
return
|
||||
|
|
|
@ -97,6 +97,7 @@ TO_PATCH = [
|
|||
'is_db_initialised',
|
||||
'maybe_do_policyd_overrides',
|
||||
'maybe_do_policyd_overrides_on_config_changed',
|
||||
'is_db_maintenance_mode',
|
||||
]
|
||||
NEUTRON_CONF_DIR = "/etc/neutron"
|
||||
|
||||
|
@ -293,6 +294,7 @@ class NeutronAPIHooksTests(CharmTestCase):
|
|||
@patch.object(hooks, 'neutron_plugin_api_subordinate_relation_joined')
|
||||
@patch.object(hooks, 'conditional_neutron_migration')
|
||||
def test_shared_db_changed(self, cond_neutron_mig, plugin_joined):
|
||||
self.is_db_maintenance_mode.return_value = False
|
||||
self.CONFIGS.complete_contexts.return_value = ['shared-db']
|
||||
self.relation_ids.return_value = ['neutron-plugin-api-subordinate:1']
|
||||
self._call_hook('shared-db-relation-changed')
|
||||
|
@ -303,6 +305,7 @@ class NeutronAPIHooksTests(CharmTestCase):
|
|||
relid='neutron-plugin-api-subordinate:1')
|
||||
|
||||
def test_shared_db_changed_partial_ctxt(self):
|
||||
self.is_db_maintenance_mode.return_value = False
|
||||
self.CONFIGS.complete_contexts.return_value = []
|
||||
self._call_hook('shared-db-relation-changed')
|
||||
self.assertFalse(self.CONFIGS.write_all.called)
|
||||
|
|
Loading…
Reference in New Issue