livepatch-charmers team mailing list archive
-
livepatch-charmers team
-
Mailing list archive
-
Message #00251
[Merge] ~barryprice/canonical-livepatch-charm/+git/trusty-handlers:master into canonical-livepatch-charm:master
Barry Price has proposed merging ~barryprice/canonical-livepatch-charm/+git/trusty-handlers:master into canonical-livepatch-charm:master.
Commit message:
Reinstate special handlers for Trusty (reverses commits 1b039b3 and a471703)
Requested reviews:
Livepatch charm developers (livepatch-charmers)
For more details, see:
https://code.launchpad.net/~barryprice/canonical-livepatch-charm/+git/trusty-handlers/+merge/363795
--
Your team Livepatch charm developers is requested to review the proposed merge of ~barryprice/canonical-livepatch-charm/+git/trusty-handlers:master into canonical-livepatch-charm:master.
diff --git a/reactive/canonical_livepatch.py b/reactive/canonical_livepatch.py
index 533e5a7..5a32acb 100644
--- a/reactive/canonical_livepatch.py
+++ b/reactive/canonical_livepatch.py
@@ -4,6 +4,7 @@ from charms.reactive.flags import register_trigger
from charmhelpers.core.host import write_file, is_container
from charmhelpers.core import hookenv
from charmhelpers.contrib.charmsupport import nrpe
+from distutils.version import LooseVersion
from os import environ, mkdir, path, uname
from subprocess import check_call, check_output, CalledProcessError
from time import sleep
@@ -173,10 +174,7 @@ def livepatch_supported():
def install_livepatch():
config = hookenv.config()
snap_channel = config.get('snap_channel')
- snap.install(
- 'canonical-livepatch',
- **{'channel': snap_channel, }
- )
+ snap.install('canonical-livepatch', **{'channel': snap_channel, })
@when('snap.installed.canonical-livepatch')
@@ -209,10 +207,17 @@ def proxy_settings():
@when('livepatch-proxy.configured')
@when_not('canonical-livepatch.connected')
def canonical_livepatch_connect():
+ # So if we've just installed snapd on a trusty system, we will not be on
+ # the HWE kernel yet and unfortunately need to reboot first!
+ current = LooseVersion(uname()[2])
+ required = LooseVersion('4.4')
uptrack_path = '/usr/sbin/uptrack-upgrade'
if path.exists(uptrack_path):
hookenv.log('Ksplice/Uptrack detected, please remove it and reboot')
unit_update('blocked', 'Remove ksplice and then reboot')
+ elif current < required:
+ hookenv.log('Reboot required, kernel {} is too old'.format(current))
+ unit_update('blocked', 'A reboot is required')
else:
unit_update('maintenance', 'Connecting to the livepatch service')
# Make sure the service is ready for us
@@ -224,6 +229,9 @@ def canonical_livepatch_connect():
@when('canonical-livepatch.connected')
@when_not('config.changed.livepatch_key', 'canonical-livepatch.active')
def init_key():
+ # If deployed under Trusty before rebooting into the HWE kernel
+ # the config-changed hook won't fire post-reboot as the state
+ # isn't tracked, but we didn't initialise yet! So, handle it here
activate_livepatch()
@@ -239,10 +247,7 @@ def change_channel():
config = hookenv.config()
snap_channel = config.get('snap_channel')
# refresh to the given channel
- snap.refresh(
- 'canonical-livepatch',
- **{'channel': snap_channel, }
- )
+ snap.refresh('canonical-livepatch', **{'channel': snap_channel, })
# Set up Nagios checks when the nrpe-external-master subordinate is related
Follow ups