launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29922
[Merge] ~cjwatson/launchpad:charm-db-changed into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:charm-db-changed into launchpad:master.
Commit message:
charm: Clear configured states on DB relation changes
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/441261
This mainly consists of pulling in a launchpad-layers change that does most of the work, but we also need to add a few handlers for charm-specific combinations of states.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:charm-db-changed into launchpad:master.
diff --git a/charm/launchpad-admin/charmcraft.yaml b/charm/launchpad-admin/charmcraft.yaml
index 2ce2b19..1f8a8e9 100644
--- a/charm/launchpad-admin/charmcraft.yaml
+++ b/charm/launchpad-admin/charmcraft.yaml
@@ -35,7 +35,7 @@ parts:
after:
- ols-layers
source: https://git.launchpad.net/launchpad-layers
- source-commit: "22811c726aca173d72ca94f83b35790474847106"
+ source-commit: "0311e05ec2e856e61a2620f68aa3ea35c0a3029b"
source-submodules: []
source-type: git
plugin: dump
diff --git a/charm/launchpad-admin/reactive/launchpad-admin.py b/charm/launchpad-admin/reactive/launchpad-admin.py
index ff76afc..d00383a 100644
--- a/charm/launchpad-admin/reactive/launchpad-admin.py
+++ b/charm/launchpad-admin/reactive/launchpad-admin.py
@@ -12,7 +12,14 @@ from charms.launchpad.base import (
strip_dsn_authentication,
update_pgpass,
)
-from charms.reactive import endpoint_from_flag, set_state, when, when_not
+from charms.reactive import (
+ endpoint_from_flag,
+ remove_state,
+ set_state,
+ when,
+ when_not,
+ when_not_all,
+)
from ols import base, postgres
from psycopg2.extensions import make_dsn, parse_dsn
@@ -133,3 +140,21 @@ def configure():
set_state("service.configured")
hookenv.status_set("active", "Ready")
+
+
+@when("service.configured")
+@when_not_all("db-admin.master.available", "session-db.master.available")
+def deconfigure():
+ remove_state("service.configured")
+
+
+@when("db-admin.database.changed", "service.configured")
+def db_admin_changed():
+ remove_state("service.configured")
+ remove_state("db-admin.database.changed")
+
+
+@when("session-db.database.changed", "service.configured")
+def session_db_changed():
+ remove_state("service.configured")
+ remove_state("session-db.database.changed")
diff --git a/charm/launchpad-appserver/charmcraft.yaml b/charm/launchpad-appserver/charmcraft.yaml
index 2fe4e10..47b8752 100644
--- a/charm/launchpad-appserver/charmcraft.yaml
+++ b/charm/launchpad-appserver/charmcraft.yaml
@@ -35,7 +35,7 @@ parts:
after:
- ols-layers
source: https://git.launchpad.net/launchpad-layers
- source-commit: "22811c726aca173d72ca94f83b35790474847106"
+ source-commit: "0311e05ec2e856e61a2620f68aa3ea35c0a3029b"
source-submodules: []
source-type: git
plugin: dump
diff --git a/charm/launchpad-appserver/reactive/launchpad-appserver.py b/charm/launchpad-appserver/reactive/launchpad-appserver.py
index 1c32282..1edc216 100644
--- a/charm/launchpad-appserver/reactive/launchpad-appserver.py
+++ b/charm/launchpad-appserver/reactive/launchpad-appserver.py
@@ -152,6 +152,18 @@ def check_is_running():
hookenv.status_set("active", "Ready")
+@when("service.configured")
+@when_not("session-db.master.available")
+def deconfigure():
+ remove_state("service.configured")
+
+
+@when("session-db.database.changed", "service.configured")
+def session_db_changed():
+ remove_state("service.configured")
+ remove_state("session-db.database.changed")
+
+
@hook("{requires:memcache}-relation-{joined,changed,broken,departed}")
def memcache_relation_changed(memcache):
remove_state("service.configured")
diff --git a/charm/launchpad/charmcraft.yaml b/charm/launchpad/charmcraft.yaml
index 54c5b16..cd51483 100644
--- a/charm/launchpad/charmcraft.yaml
+++ b/charm/launchpad/charmcraft.yaml
@@ -35,7 +35,7 @@ parts:
after:
- ols-layers
source: https://git.launchpad.net/launchpad-layers
- source-commit: "22811c726aca173d72ca94f83b35790474847106"
+ source-commit: "0311e05ec2e856e61a2620f68aa3ea35c0a3029b"
source-submodules: []
source-type: git
plugin: dump