livepatch-charmers team mailing list archive
-
livepatch-charmers team
-
Mailing list archive
-
Message #00008
[Merge] ~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm:master into canonical-livepatch-charm:master
Barry Price has proposed merging ~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm:master into canonical-livepatch-charm:master.
Commit message:
First pass at Trusty (14.04) support - not fully tested yet
Requested reviews:
Livepatch charm developers (livepatch-charmers)
For more details, see:
https://code.launchpad.net/~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm/+merge/324996
--
Your team Livepatch charm developers is requested to review the proposed merge of ~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm:master into canonical-livepatch-charm:master.
diff --git a/metadata.yaml b/metadata.yaml
index c70bd26..57a3db5 100644
--- a/metadata.yaml
+++ b/metadata.yaml
@@ -1,7 +1,7 @@
name: canonical-livepatch
summary: Ubuntu Linux Livepatching Utility and Daemon
maintainer: Livepatch charm developers <livepatch-charmers@xxxxxxxxxxxxxxxxxxx>
-series: ['xenial']
+series: ['trusty', 'xenial']
description: |
This charms installs and configures the Ubuntu Linux Livepatching Utility and Daemon
tags:
diff --git a/reactive/canonical_livepatch.py b/reactive/canonical_livepatch.py
index 8333c6d..f95b9bc 100644
--- a/reactive/canonical_livepatch.py
+++ b/reactive/canonical_livepatch.py
@@ -7,6 +7,23 @@ from time import sleep
from os import path
from yaml import load, dump
from platform import release
+from distutils.version import LooseVersion
+
+
+def get_series():
+ return check_output(['lsb_release', '-sc'],
+ universal_newlines=True).strip()
+
+
+def is_xenial_kernel():
+ uname = check_output(['uname', '-r'],
+ universal_newlines=True).strip()
+ current = LooseVersion(uname)
+ required = LooseVersion('4.4')
+ if current < required:
+ return False
+ else:
+ return True
def file_to_units(local_path, unit_path):
@@ -138,9 +155,9 @@ def configure_proxies(http_proxy=None, https_proxy=None, no_proxy=None):
def restart_livepatch():
# do a clean stop of the service first, 'restart' seems fragile right now
cmd = [
- '/usr/sbin/service',
- 'snap.canonical-livepatch.canonical-livepatchd',
- 'stop'
+ '/bin/systemctl',
+ 'stop',
+ 'snap.canonical-livepatch.canonical-livepatchd.service',
]
hookenv.log('Stopping canonical-livepatch service')
try:
@@ -150,9 +167,9 @@ def restart_livepatch():
# and now try to start it again, it may fail the first time!
cmd = [
- '/usr/sbin/service',
- 'snap.canonical-livepatch.canonical-livepatchd',
- 'start'
+ '/bin/systemctl',
+ 'start',
+ 'snap.canonical-livepatch.canonical-livepatchd.service',
]
hookenv.log('Starting canonical-livepatch service')
try:
@@ -169,10 +186,16 @@ def restart_livepatch():
@when_not('canonical-livepatch.connected')
def canonical_livepatch_connect():
- # Make sure the service is ready for us
- wait_for_livepatch()
+ # 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!
+ if get_series() == 'trusty' and is_xenial_kernel() is False:
+ unit_update('maintenance', 'Rebooting into Xenial kernel')
+ check_call(['juju-reboot'], universal_newlines=True)
+ else:
+ # Make sure the service is ready for us
+ wait_for_livepatch()
- set_state('canonical-livepatch.connected')
+ set_state('canonical-livepatch.connected')
@when('canonical-livepatch.connected')
diff --git a/tests/99-autogen b/tests/99-autogen
index aa6f15f..7bc8f1e 100755
--- a/tests/99-autogen
+++ b/tests/99-autogen
@@ -10,7 +10,7 @@ class TestDeployment(unittest.TestCase):
def setUpClass(cls):
cls.deployment = amulet.Deployment(series='xenial')
- # deploy postgresql as our parent, it's a well-behaved xenial charm
+ # deploy postgresql as our parent, it's a well-behaved charm
cls.deployment.add('postgresql')
# deploy our own charm
Follow ups