← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/lp-signing:fix-configure-hook into lp-signing:master

 

Colin Watson has proposed merging ~cjwatson/lp-signing:fix-configure-hook into lp-signing:master.

Commit message:
Fix the charm's configure hook

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/lp-signing/+git/lp-signing/+merge/381820

The configure hook shouldn't run if the service is already configured.

If the db-admin relation hasn't been fully joined yet, then postgres.get_db_uris will crash.  Avoid this by just returning if pgsql.master is None; the usual reactive charm machinery will call us back later.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/lp-signing:fix-configure-hook into lp-signing:master.
diff --git a/charm/lp-signing/reactive/lp-signing.py b/charm/lp-signing/reactive/lp-signing.py
index 3a881ee..8dbed78 100644
--- a/charm/lp-signing/reactive/lp-signing.py
+++ b/charm/lp-signing/reactive/lp-signing.py
@@ -17,6 +17,7 @@ from charms.reactive import (
     remove_state,
     set_state,
     when,
+    when_not,
     )
 from ols import (
     base,
@@ -47,7 +48,11 @@ def configure_rsync():
 
 
 @when('ols.configured', 'db.master.available')
+@when_not('service.configured')
 def configure(pgsql):
+    if pgsql.master is None:
+        return
+
     config = hookenv.config()
     config_path = base.service_config_path()
     svc_config = dict(config)