Merge charm-hw-health:bug/2044387 into charm-hw-health:master

Proposed by Facundo Ciccioli
Status: Rejected
Rejected by: Facundo Ciccioli
Proposed branch: charm-hw-health:bug/2044387
Merge into: charm-hw-health:master
Diff against target: 35 lines (+10/-1)
1 file modified
src/files/nvme/check_nvme.py (+10/-1)
Reviewer Review Type Date Requested Status
Robert Gildein Needs Fixing
BootStack Reviewers Pending
Review via email: mp+456193@code.launchpad.net

Commit message

Don't bail out when the nvme command fails

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
Robert Gildein (rgildein) wrote :

Can you provide unit tests for these changes. Thanks
FYI: Our Jenkins is down, so CI not working now.

review: Needs Fixing

Unmerged commits

e605730... by Facundo Ciccioli

Don't bail out when the nvme command fails

Take note of it and keep going. Raise to UNKNOWN if some command failed
and no criticals were found.

Fixes bug #2044387

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/files/nvme/check_nvme.py b/src/files/nvme/check_nvme.py
index 14468cb..fd40071 100755
--- a/src/files/nvme/check_nvme.py
+++ b/src/files/nvme/check_nvme.py
@@ -21,6 +21,7 @@ def parse_output(warning_used, critical_used): # noqa: C901
21 keymap = {}21 keymap = {}
22 critical = False22 critical = False
23 warning = False23 warning = False
24 unknown = False
24 alloutputs = []25 alloutputs = []
25 for device in glob.glob("/dev/nvme*"):26 for device in glob.glob("/dev/nvme*"):
26 if not NVME_RE.match(device):27 if not NVME_RE.match(device):
@@ -31,7 +32,12 @@ def parse_output(warning_used, critical_used): # noqa: C901
31 )32 )
32 except subprocess.CalledProcessError as error:33 except subprocess.CalledProcessError as error:
33 print("nvme check error: {}".format(error))34 print("nvme check error: {}".format(error))
34 return35 status = ("UNKNOWN: {} error running nvme command: {}").format(
36 device, error
37 )
38 unknown = True
39 alloutputs.append(status)
40 continue
3541
36 for line in output.decode(errors="ignore").splitlines():42 for line in output.decode(errors="ignore").splitlines():
37 datavalues_re = re.match(r"^(\w+)\s+:\s+([\d.]+)", line.strip())43 datavalues_re = re.match(r"^(\w+)\s+:\s+([\d.]+)", line.strip())
@@ -70,6 +76,9 @@ def parse_output(warning_used, critical_used): # noqa: C901
70 if critical:76 if critical:
71 raise CriticalError("\n".join(alloutputs))77 raise CriticalError("\n".join(alloutputs))
7278
79 if unknown:
80 raise UnknownError("\n".join(alloutputs))
81
73 if warning:82 if warning:
74 raise WarnError("\n".join(alloutputs))83 raise WarnError("\n".join(alloutputs))
7584

Subscribers

No one subscribed via source and target branches