← Back to team overview

livepatch-charmers team mailing list archive

[Merge] ~wgrant/canonical-livepatch-charm:update-status-alternative into canonical-livepatch-charm:master

 

William Grant has proposed merging ~wgrant/canonical-livepatch-charm:update-status-alternative into canonical-livepatch-charm:master.

Commit message:
Only skip nagios configuration on update-status.

Requested reviews:
  Livepatch charm developers (livepatch-charmers)

For more details, see:
https://code.launchpad.net/~wgrant/canonical-livepatch-charm/+git/canonical-livepatch-charm/+merge/324038

Only skip nagios configuration on update-status.

The previous implementation's nagios-configured state meant it wouldn't
respond to changes in the nrpe relation, just local nrpe config. This
was particularly problematic when the nrpe exports were be written out
before the nrpe charm had set nagios_hostname, causing the exports to
name the machine after the canonical-livepatch unit rather than the
principal.
-- 
Your team Livepatch charm developers is requested to review the proposed merge of ~wgrant/canonical-livepatch-charm:update-status-alternative into canonical-livepatch-charm:master.
diff --git a/reactive/canonical_livepatch.py b/reactive/canonical_livepatch.py
index 9aa91a4..8333c6d 100644
--- a/reactive/canonical_livepatch.py
+++ b/reactive/canonical_livepatch.py
@@ -238,20 +238,11 @@ def update_livepatch_proxy():
     update_key()
 
 
-@when('config.changed.nagios_context')
-def update_nagios_context():
-    remove_state('canonical-livepatch.nagios-configured')
-
-
-@when('config.changed.nagios_servicegroups')
-def update_nagios_servicegroups():
-    remove_state('canonical-livepatch.nagios-configured')
-
-
 @when('snap.installed.canonical-livepatch')
 @when('nrpe-external-master.available')
-@when_not('canonical-livepatch.nagios-configured')
 def configure_nagios(nagios):
+    if hookenv.hook_name() == 'update-status':
+        return
 
     # Ask charmhelpers.contrib.charmsupport's nrpe to work out our hostname
     hostname = nrpe.get_nagios_hostname()
@@ -286,7 +277,9 @@ def configure_nagios(nagios):
     )
 
     nrpe_setup.write()
-    set_state('canonical-livepatch.nagios-configured')
+
+    # Remove obsolete state from older charm.
+    remove_state('canonical-livepatch.nagios-configured')
 
 
 @when('snap.installed.canonical-livepatch')

Follow ups