livepatch-charmers team mailing list archive
-
livepatch-charmers team
-
Mailing list archive
-
Message #00193
[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:
Improve NRPE error reporting, use YAML module for snap channel parsing, add a refresh action
Requested reviews:
Livepatch charm developers (livepatch-charmers)
For more details, see:
https://code.launchpad.net/~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm/+merge/355063
--
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/actions/actions.py b/actions/actions.py
index d618758..a8ac675 100755
--- a/actions/actions.py
+++ b/actions/actions.py
@@ -42,6 +42,16 @@ def deactivate():
hookenv.action_set(dict(result='Deactivated'))
+def refresh():
+ cmd = ['/snap/bin/canonical-livepatch', 'refresh']
+ try:
+ check_output(cmd, universal_newlines=True)
+ except CalledProcessError as e:
+ hookenv.action_fail('Unable to refresh: {}'.format(str(e)))
+ return
+ hookenv.action_set(dict(result='Refreshed'))
+
+
def main(argv):
action = os.path.basename(argv[0])
params = hookenv.action_get()
diff --git a/actions/refresh b/actions/refresh
new file mode 120000
index 0000000..405a394
--- /dev/null
+++ b/actions/refresh
@@ -0,0 +1 @@
+actions.py
\ No newline at end of file
diff --git a/files/check_canonical-livepatch.py b/files/check_canonical-livepatch.py
index 3a13062..e4eaa91 100755
--- a/files/check_canonical-livepatch.py
+++ b/files/check_canonical-livepatch.py
@@ -53,13 +53,15 @@ def check_status():
line = line.strip()
if 'State:' in line:
if 'apply-failed' in line:
- err_lines.append('Patch failed')
+ err_lines.append('Livepatch failed to apply patches. ')
elif 'check-failed' in line:
- err_lines.append('Check failed')
+ err_lines.append('Livepatch failed to check the remote service for patches. ')
elif 'unknown' in line:
- err_lines.append('Unknown error')
+ err_lines.append('Livepatch reports an unknown error. ')
+ elif 'kernel-upgrade-required' in line:
+ err_lines.append('A kernel upgrade (and reboot) is required. ')
elif 'Machine is not enabled' in line:
- err_lines.append('Machine is not enabled')
+ err_lines.append('Machine is not enabled. ')
if err_lines:
err = " ".join(err_lines)
diff --git a/tests/99-autogen b/tests/99-autogen
index f4b0af9..d7bed72 100755
--- a/tests/99-autogen
+++ b/tests/99-autogen
@@ -3,6 +3,7 @@
import amulet
import unittest
from time import sleep
+from yaml import safe_load
class TestDeployment(unittest.TestCase):
@@ -97,7 +98,6 @@ class TestDeployment(unittest.TestCase):
'.cfg'.format(test_context_name))
self.assertEqual(exit_code, 0)
-
def test_channel_change(self):
livepatch = self.deployment.sentry['canonical-livepatch'][0]
@@ -106,10 +106,8 @@ class TestDeployment(unittest.TestCase):
self.assertEqual(exit_code, 0)
# confirm we're tracking 'stable'
- channel = ''
- for line in output.split('\n'):
- if line.startswith('tracking:'):
- channel = line.strip().split(' ')[-1]
+ output_yaml = safe_load(output)
+ channel = output_yaml['tracking']
self.assertEqual(channel, 'stable')
# change channel to 'beta'
@@ -125,13 +123,10 @@ class TestDeployment(unittest.TestCase):
self.assertEqual(exit_code, 0)
# confirm we're tracking 'beta'
- channel = ''
- for line in output.split('\n'):
- if line.startswith('tracking:'):
- channel = line.strip().split(' ')[-1]
+ output_yaml = safe_load(output)
+ channel = output_yaml['tracking']
self.assertEqual(channel, 'beta')
-
def test_nagios_servicegroup_change(self):
livepatch = self.deployment.sentry['canonical-livepatch'][0]
Follow ups