Limit number of times ensure_initial_admin is called
Run on database initialization and after config changed. Change-Id: Id4f1bb7f7931b214b37d097988c013b053a85d22
This commit is contained in:
parent
c5f616e99b
commit
70414878d5
|
@ -232,6 +232,10 @@ def config_changed_postupgrade():
|
|||
if snap_install_requested() and not is_unit_paused_set():
|
||||
service_restart('snap.keystone.*')
|
||||
|
||||
if (is_db_initialised() and is_elected_leader(CLUSTER_RES) and not
|
||||
is_unit_paused_set()):
|
||||
ensure_initial_admin(config)
|
||||
|
||||
update_all_identity_relation_units()
|
||||
update_all_domain_backends()
|
||||
update_all_fid_backends()
|
||||
|
@ -273,9 +277,6 @@ def update_all_identity_relation_units(check_db_ready=True):
|
|||
"updates", level=INFO)
|
||||
return
|
||||
|
||||
if is_elected_leader(CLUSTER_RES):
|
||||
ensure_initial_admin(config)
|
||||
|
||||
log('Firing identity_changed hook for all related services.')
|
||||
for rid in relation_ids('identity-service'):
|
||||
for unit in related_units(rid):
|
||||
|
@ -330,6 +331,7 @@ def leader_init_db_if_ready(use_current_context=False):
|
|||
return
|
||||
|
||||
migrate_database()
|
||||
ensure_initial_admin(config)
|
||||
# Ensure any existing service entries are updated in the
|
||||
# new database backend. Also avoid duplicate db ready check.
|
||||
update_all_identity_relation_units(check_db_ready=False)
|
||||
|
|
|
@ -256,6 +256,7 @@ class KeystoneRelationTests(CharmTestCase):
|
|||
self.assertTrue(update.called)
|
||||
self.assertTrue(mock_update_domains.called)
|
||||
|
||||
@patch.object(hooks, 'is_db_initialised')
|
||||
@patch.object(hooks, 'update_all_domain_backends')
|
||||
@patch.object(hooks, 'update_all_identity_relation_units')
|
||||
@patch.object(hooks, 'run_in_apache')
|
||||
|
@ -270,7 +271,8 @@ class KeystoneRelationTests(CharmTestCase):
|
|||
mock_cluster_joined,
|
||||
mock_log,
|
||||
mock_run_in_apache, update,
|
||||
mock_update_domains):
|
||||
mock_update_domains,
|
||||
mock_is_db_initialised):
|
||||
|
||||
def fake_relation_ids(relation):
|
||||
rids = {}
|
||||
|
@ -282,6 +284,7 @@ class KeystoneRelationTests(CharmTestCase):
|
|||
|
||||
mock_run_in_apache.return_value = False
|
||||
self.openstack_upgrade_available.return_value = False
|
||||
mock_is_db_initialised.return_value = True
|
||||
|
||||
hooks.config_changed()
|
||||
|
||||
|
@ -817,7 +820,6 @@ class KeystoneRelationTests(CharmTestCase):
|
|||
self.is_elected_leader.return_value = True
|
||||
is_db_initialized.return_value = True
|
||||
hooks.update_all_identity_relation_units(check_db_ready=False)
|
||||
self.assertTrue(self.ensure_initial_admin.called)
|
||||
# Still updates relations
|
||||
self.assertTrue(self.relation_ids.called)
|
||||
|
||||
|
|
Loading…
Reference in New Issue