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
diff --git a/Makefile b/Makefile
index d608afb..e7f78ad 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ testdeps:
14 @sudo apt-get update14 @sudo apt-get update
15 @sudo apt-get install -y make flake8 python3-flake8 python3-pip python-pip snapd libffi-dev15 @sudo apt-get install -y make flake8 python3-flake8 python3-pip python-pip snapd libffi-dev
16 @which juju >/dev/null || (sudo snap install juju --classic)16 @which juju >/dev/null || (sudo snap install juju --classic)
17 @which charm >/dev/null || (sudo snap install charm)17 @which charm >/dev/null || (sudo snap install charm --classic)
18 @which bundletester >/dev/null || (pip2 install bundletester juju-deployer)18 @which bundletester >/dev/null || (pip2 install bundletester juju-deployer)
19 @pip3 install amulet19 @pip3 install amulet
2020
diff --git a/config.yaml b/config.yaml
index 556aaee..ee164fe 100644
--- a/config.yaml
+++ b/config.yaml
@@ -13,22 +13,6 @@ options:
13 description: |13 description: |
14 The address of a proxy server to use for livepatch traffic14 The address of a proxy server to use for livepatch traffic
15 e.g. http://proxy.example.com:312815 e.g. http://proxy.example.com:3128
16 nagios_context:
17 default: "juju"
18 type: string
19 description: |
20 Used by the nrpe-external-master subordinate charm.
21 A string that will be prepended to instance name to set the host name
22 in nagios. So for instance the hostname would be something like:
23 juju-myservice-0
24 If you're running multiple environments with the same services in them
25 this allows you to differentiate between them.
26 nagios_servicegroups:
27 default: ""
28 type: string
29 description: >
30 A comma-separated list of nagios servicegroups.
31 If left empty, the nagios_context will be used as the servicegroup.
32 snap_channel:16 snap_channel:
33 default: "stable"17 default: "stable"
34 type: string18 type: string
diff --git a/layer.yaml b/layer.yaml
index 0fd758a..fabbd11 100644
--- a/layer.yaml
+++ b/layer.yaml
@@ -1,7 +1,7 @@
1includes:1includes:
2 - layer:basic2 - layer:basic
3 - layer:nagios
3 - layer:snap4 - layer:snap
4 - interface:nrpe-external-master
5options:5options:
6 basic:6 basic:
7 use_venv: true7 use_venv: true
diff --git a/reactive/canonical_livepatch.py b/reactive/canonical_livepatch.py
index a1bac0d..3f30019 100644
--- a/reactive/canonical_livepatch.py
+++ b/reactive/canonical_livepatch.py
@@ -1,10 +1,9 @@
1from charms.layer import snap1from charms.layer import snap
2from charms.reactive import when, when_not, set_flag, clear_flag2from charms.reactive import when, when_not, set_flag, clear_flag, hook
3from charms.reactive.flags import register_trigger3from charms.reactive.flags import register_trigger
4from charmhelpers.core.host import write_file, is_container4from charmhelpers.core.host import write_file, is_container
5from charmhelpers.core import hookenv5from charmhelpers.core import hookenv
6from charmhelpers.contrib.charmsupport import nrpe6from charmhelpers.contrib.charmsupport import nrpe
7from distutils.version import LooseVersion
8from os import environ, mkdir, path, uname7from os import environ, mkdir, path, uname
9from subprocess import check_call, check_output, CalledProcessError8from subprocess import check_call, check_output, CalledProcessError
10from time import sleep9from time import sleep
@@ -210,17 +209,10 @@ def proxy_settings():
210@when('livepatch-proxy.configured')209@when('livepatch-proxy.configured')
211@when_not('canonical-livepatch.connected')210@when_not('canonical-livepatch.connected')
212def canonical_livepatch_connect():211def canonical_livepatch_connect():
213 # So if we've just installed snapd on a trusty system, we will not be on
214 # the HWE kernel yet and unfortunately need to reboot first!
215 current = LooseVersion(uname()[2])
216 required = LooseVersion('4.4')
217 uptrack_path = '/usr/sbin/uptrack-upgrade'212 uptrack_path = '/usr/sbin/uptrack-upgrade'
218 if path.exists(uptrack_path):213 if path.exists(uptrack_path):
219 hookenv.log('Ksplice/Uptrack detected, please remove it and reboot')214 hookenv.log('Ksplice/Uptrack detected, please remove it and reboot')
220 unit_update('blocked', 'Remove ksplice and then reboot')215 unit_update('blocked', 'Remove ksplice and then reboot')
221 elif current < required:
222 hookenv.log('Reboot required, kernel {} is too old'.format(current))
223 unit_update('blocked', 'A reboot is required')
224 else:216 else:
225 unit_update('maintenance', 'Connecting to the livepatch service')217 unit_update('maintenance', 'Connecting to the livepatch service')
226 # Make sure the service is ready for us218 # Make sure the service is ready for us
@@ -232,9 +224,6 @@ def canonical_livepatch_connect():
232@when('canonical-livepatch.connected')224@when('canonical-livepatch.connected')
233@when_not('config.changed.livepatch_key', 'canonical-livepatch.active')225@when_not('config.changed.livepatch_key', 'canonical-livepatch.active')
234def init_key():226def init_key():
235 # If deployed under Trusty before rebooting into the HWE kernel
236 # the config-changed hook won't fire post-reboot as the state
237 # isn't tracked, but we didn't initialise yet! So, handle it here
238 activate_livepatch()227 activate_livepatch()
239228
240229
@@ -256,7 +245,9 @@ def change_channel():
256 )245 )
257246
258247
248# Set up Nagios checks when the nrpe-external-master subordinate is related
259@when('nrpe-external-master.available')249@when('nrpe-external-master.available')
250@when_not('canonical-livepatch.nagios-setup.complete')
260def configure_nagios(nagios):251def configure_nagios(nagios):
261 if hookenv.hook_name() == 'update-status':252 if hookenv.hook_name() == 'update-status':
262 return253 return
@@ -292,10 +283,19 @@ def configure_nagios(nagios):
292283
293 nrpe_setup.write()284 nrpe_setup.write()
294285
295 # Remove obsolete state from older charm.286 # Remove obsolete state from older charm, if present
296 clear_flag('canonical-livepatch.nagios-configured')287 clear_flag('canonical-livepatch.nagios-configured')
288 # Set our preferred state
289 set_flag('canonical-livepatch.nagios-setup.complete')
297290
298291
299@when('snap.installed.canonical-livepatch', 'canonical-livepatch.active')292@when('snap.installed.canonical-livepatch', 'canonical-livepatch.active')
300def update_kernel_version():293def update_kernel_version():
301 unit_update()294 unit_update()
295
296
297# This is triggered on any config-changed, and after an upgrade-charm - you
298# don't get the latter with @when('config.changed')
299@hook('config-changed')
300def set_nrpe_flag():
301 clear_flag('canonical-livepatch.nagios-setup.complete')

Subscribers

People subscribed via source and target branches