Merge ~barryprice/charm-canonical-livepatch/+git/canonical-livepatch-charm:master into ~livepatch-charmers/charm-canonical-livepatch:master

Proposed by Barry Price
Status: Merged
Approved by: Jacek Nykis
Approved revision: a47170379343b76575f8637cde5a18e9883bfbdf
Merged at revision: a71388035f67f69542bb1685da40f488b396c2e1
Proposed branch: ~barryprice/charm-canonical-livepatch/+git/canonical-livepatch-charm:master
Merge into: ~livepatch-charmers/charm-canonical-livepatch:master
Diff against target: 128 lines (+15/-31)
4 files modified
Makefile (+1/-1)
config.yaml (+0/-16)
layer.yaml (+1/-1)
reactive/canonical_livepatch.py (+13/-13)
Reviewer Review Type Date Requested Status
Livepatch charm developers Pending
Review via email: mp+356576@code.launchpad.net

Commit message

Use layer:nagios instead of interface:nrpe-external-master, and address LP#1795902

Also remove the reboot logic for Trusty, to address LP#1800885

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision a71388035f67f69542bb1685da40f488b396c2e1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Makefile b/Makefile
2index d608afb..e7f78ad 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -14,7 +14,7 @@ testdeps:
6 @sudo apt-get update
7 @sudo apt-get install -y make flake8 python3-flake8 python3-pip python-pip snapd libffi-dev
8 @which juju >/dev/null || (sudo snap install juju --classic)
9- @which charm >/dev/null || (sudo snap install charm)
10+ @which charm >/dev/null || (sudo snap install charm --classic)
11 @which bundletester >/dev/null || (pip2 install bundletester juju-deployer)
12 @pip3 install amulet
13
14diff --git a/config.yaml b/config.yaml
15index 556aaee..ee164fe 100644
16--- a/config.yaml
17+++ b/config.yaml
18@@ -13,22 +13,6 @@ options:
19 description: |
20 The address of a proxy server to use for livepatch traffic
21 e.g. http://proxy.example.com:3128
22- nagios_context:
23- default: "juju"
24- type: string
25- description: |
26- Used by the nrpe-external-master subordinate charm.
27- A string that will be prepended to instance name to set the host name
28- in nagios. So for instance the hostname would be something like:
29- juju-myservice-0
30- If you're running multiple environments with the same services in them
31- this allows you to differentiate between them.
32- nagios_servicegroups:
33- default: ""
34- type: string
35- description: >
36- A comma-separated list of nagios servicegroups.
37- If left empty, the nagios_context will be used as the servicegroup.
38 snap_channel:
39 default: "stable"
40 type: string
41diff --git a/layer.yaml b/layer.yaml
42index 0fd758a..fabbd11 100644
43--- a/layer.yaml
44+++ b/layer.yaml
45@@ -1,7 +1,7 @@
46 includes:
47 - layer:basic
48+ - layer:nagios
49 - layer:snap
50- - interface:nrpe-external-master
51 options:
52 basic:
53 use_venv: true
54diff --git a/reactive/canonical_livepatch.py b/reactive/canonical_livepatch.py
55index a1bac0d..3f30019 100644
56--- a/reactive/canonical_livepatch.py
57+++ b/reactive/canonical_livepatch.py
58@@ -1,10 +1,9 @@
59 from charms.layer import snap
60-from charms.reactive import when, when_not, set_flag, clear_flag
61+from charms.reactive import when, when_not, set_flag, clear_flag, hook
62 from charms.reactive.flags import register_trigger
63 from charmhelpers.core.host import write_file, is_container
64 from charmhelpers.core import hookenv
65 from charmhelpers.contrib.charmsupport import nrpe
66-from distutils.version import LooseVersion
67 from os import environ, mkdir, path, uname
68 from subprocess import check_call, check_output, CalledProcessError
69 from time import sleep
70@@ -210,17 +209,10 @@ def proxy_settings():
71 @when('livepatch-proxy.configured')
72 @when_not('canonical-livepatch.connected')
73 def canonical_livepatch_connect():
74- # So if we've just installed snapd on a trusty system, we will not be on
75- # the HWE kernel yet and unfortunately need to reboot first!
76- current = LooseVersion(uname()[2])
77- required = LooseVersion('4.4')
78 uptrack_path = '/usr/sbin/uptrack-upgrade'
79 if path.exists(uptrack_path):
80 hookenv.log('Ksplice/Uptrack detected, please remove it and reboot')
81 unit_update('blocked', 'Remove ksplice and then reboot')
82- elif current < required:
83- hookenv.log('Reboot required, kernel {} is too old'.format(current))
84- unit_update('blocked', 'A reboot is required')
85 else:
86 unit_update('maintenance', 'Connecting to the livepatch service')
87 # Make sure the service is ready for us
88@@ -232,9 +224,6 @@ def canonical_livepatch_connect():
89 @when('canonical-livepatch.connected')
90 @when_not('config.changed.livepatch_key', 'canonical-livepatch.active')
91 def init_key():
92- # If deployed under Trusty before rebooting into the HWE kernel
93- # the config-changed hook won't fire post-reboot as the state
94- # isn't tracked, but we didn't initialise yet! So, handle it here
95 activate_livepatch()
96
97
98@@ -256,7 +245,9 @@ def change_channel():
99 )
100
101
102+# Set up Nagios checks when the nrpe-external-master subordinate is related
103 @when('nrpe-external-master.available')
104+@when_not('canonical-livepatch.nagios-setup.complete')
105 def configure_nagios(nagios):
106 if hookenv.hook_name() == 'update-status':
107 return
108@@ -292,10 +283,19 @@ def configure_nagios(nagios):
109
110 nrpe_setup.write()
111
112- # Remove obsolete state from older charm.
113+ # Remove obsolete state from older charm, if present
114 clear_flag('canonical-livepatch.nagios-configured')
115+ # Set our preferred state
116+ set_flag('canonical-livepatch.nagios-setup.complete')
117
118
119 @when('snap.installed.canonical-livepatch', 'canonical-livepatch.active')
120 def update_kernel_version():
121 unit_update()
122+
123+
124+# This is triggered on any config-changed, and after an upgrade-charm - you
125+# don't get the latter with @when('config.changed')
126+@hook('config-changed')
127+def set_nrpe_flag():
128+ clear_flag('canonical-livepatch.nagios-setup.complete')

Subscribers

People subscribed via source and target branches