← Back to team overview

livepatch-charmers team mailing list archive

[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:
This is such a mess -see linked bug, which was right the first time.

Un-reverse the reversal of the fix(!)

Requested reviews:
  Livepatch charm developers (livepatch-charmers)
Related bugs:
  Bug #1778447 in Canonical Livepatch Charm: "Nagios check goes UNKNOWN when check-failed"
  https://bugs.launchpad.net/canonical-livepatch-charm/+bug/1778447

For more details, see:
https://code.launchpad.net/~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm/+merge/348750
-- 
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/files/check_canonical-livepatch.py b/files/check_canonical-livepatch.py
index 4e6d54d..3a13062 100755
--- a/files/check_canonical-livepatch.py
+++ b/files/check_canonical-livepatch.py
@@ -3,7 +3,6 @@
 # Copyright (C) 2016 Canonical Ltd.
 
 import os
-import sys
 import nagios_plugin
 from subprocess import check_output, call
 
@@ -17,8 +16,7 @@ def check_package_installed():
     try:
         check_output(cmd, universal_newlines=True)
     except Exception:
-        print("canonical-livepatch snap is not installed")
-        sys.exit(2)
+        raise nagios_plugin.CriticalError("canonical-livepatch snap is not installed")
 
 
 ##############################################################################
@@ -65,12 +63,10 @@ def check_status():
 
     if err_lines:
         err = " ".join(err_lines)
-        print(err)
-        sys.exit(2)
+        raise nagios_plugin.CriticalError(err)
     elif wrn_lines:
         wrn = " ".join(wrn_lines)
-        print(wrn)
-        sys.exit(1)
+        raise nagios_plugin.WarnError(wrn)
 
 
 def lsb_release():
@@ -108,8 +104,9 @@ def is_container():
 def main():
     arch = os.uname()[4]
     if arch not in supported_archs:
-        print("canonical-livepatch not supported on this architecture ({}).".format(arch))
-        sys.exit(1)
+        raise nagios_plugin.CriticalError(
+            "canonical-livepatch not supported on this architecture ({}).".format(arch)
+        )
     elif is_container():
         print("canonical-livepatch not needed in OS containers.")
     else:

Follow ups