Merge ~cjwatson/launchpad-layers:db-changed into launchpad-layers:main

Proposed by Colin Watson
Status: Merged
Merged at revision: 0311e05ec2e856e61a2620f68aa3ea35c0a3029b
Proposed branch: ~cjwatson/launchpad-layers:db-changed
Merge into: launchpad-layers:main
Diff against target: 42 lines (+17/-0)
1 file modified
launchpad-base/reactive/launchpad-base.py (+17/-0)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Review via email: mp+441077@code.launchpad.net

Commit message

Clear configured states on DB relation changes

Description of the change

Otherwise we don't notice if (for example) the relation tells us that a DB password has changed, or if the relation is broken.

To post a comment you must log in.
Revision history for this message
Guruprasad (lgp171188) wrote :

LGTM 👍🏼

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/launchpad-base/reactive/launchpad-base.py b/launchpad-base/reactive/launchpad-base.py
2index 4bec15d..3063019 100644
3--- a/launchpad-base/reactive/launchpad-base.py
4+++ b/launchpad-base/reactive/launchpad-base.py
5@@ -22,6 +22,7 @@ from charms.reactive import (
6 when_any,
7 when_none,
8 when_not,
9+ when_not_all,
10 )
11 from ols import base, postgres
12
13@@ -110,6 +111,15 @@ def configure():
14 set_state("launchpad.base.configured")
15
16
17+@when("launchpad.base.configured")
18+@when_not_all(
19+ "ols.configured", "db.master.available", "launchpad.rabbitmq.available"
20+)
21+def deconfigure():
22+ remove_state("launchpad.base.configured")
23+ remove_state("service.configured")
24+
25+
26 @hook("upgrade-charm")
27 def upgrade_charm():
28 # The ols layer takes care of removing the ols.service.installed,
29@@ -133,6 +143,13 @@ def config_changed():
30 remove_state("service.configured")
31
32
33+@when("db.database.changed", "launchpad.base.configured")
34+def db_changed():
35+ remove_state("launchpad.base.configured")
36+ remove_state("service.configured")
37+ remove_state("db.database.changed")
38+
39+
40 @hook("{requires:rabbitmq}-relation-changed")
41 def rabbitmq_relation_changed(*args):
42 remove_state("launchpad.base.configured")

Subscribers

People subscribed via source and target branches