From a87b1011066650dbfc924501202d7048f6f022bc Mon Sep 17 00:00:00 2001 From: Paul Goins Date: Fri, 22 Feb 2019 10:12:32 -0800 Subject: [PATCH] Unset DB init flag on shared-db relation removal The keystone charm sets db-initialised to true after initializing the database the first time. However, if the database application is removed, this flag is not unset. This results in breakage on attempts to re-add a shared-db relation with a new database application, as the charm will not attempt to re-initialize the database prior to doing DB operations. This fix simply ensures that we unset this flag prior to finalizing removal of the shared-db relation. Change-Id: I78ae12fda05ce006939b2d90a3d738bacb815915 Closes-Bug: #1797229 --- hooks/keystone_hooks.py | 8 ++++++++ hooks/shared-db-relation-broken | 1 + hooks/shared-db-relation-departed | 1 + 3 files changed, 10 insertions(+) create mode 120000 hooks/shared-db-relation-broken create mode 120000 hooks/shared-db-relation-departed diff --git a/hooks/keystone_hooks.py b/hooks/keystone_hooks.py index 2eb8e2eb..f3491301 100755 --- a/hooks/keystone_hooks.py +++ b/hooks/keystone_hooks.py @@ -50,6 +50,7 @@ from charmhelpers.core.hookenv import ( open_port, is_leader, relation_id, + leader_set, ) from charmhelpers.core.host import ( @@ -393,6 +394,13 @@ def db_changed(): update_all_identity_relation_units() +@hooks.hook('shared-db-relation-departed', + 'shared-db-relation-broken') +def db_departed_or_broken(): + if is_leader(): + leader_set({'db-initialised': None}) + + @hooks.hook('identity-service-relation-changed') @restart_on_change(restart_map(), restart_functions=restart_function_map()) def identity_changed(relation_id=None, remote_unit=None): diff --git a/hooks/shared-db-relation-broken b/hooks/shared-db-relation-broken new file mode 120000 index 00000000..dd3b3eff --- /dev/null +++ b/hooks/shared-db-relation-broken @@ -0,0 +1 @@ +keystone_hooks.py \ No newline at end of file diff --git a/hooks/shared-db-relation-departed b/hooks/shared-db-relation-departed new file mode 120000 index 00000000..dd3b3eff --- /dev/null +++ b/hooks/shared-db-relation-departed @@ -0,0 +1 @@ +keystone_hooks.py \ No newline at end of file