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
1diff --git a/src/files/nvme/check_nvme.py b/src/files/nvme/check_nvme.py
2index 14468cb..fd40071 100755
3--- a/src/files/nvme/check_nvme.py
4+++ b/src/files/nvme/check_nvme.py
5@@ -21,6 +21,7 @@ def parse_output(warning_used, critical_used): # noqa: C901
6 keymap = {}
7 critical = False
8 warning = False
9+ unknown = False
10 alloutputs = []
11 for device in glob.glob("/dev/nvme*"):
12 if not NVME_RE.match(device):
13@@ -31,7 +32,12 @@ def parse_output(warning_used, critical_used): # noqa: C901
14 )
15 except subprocess.CalledProcessError as error:
16 print("nvme check error: {}".format(error))
17- return
18+ status = ("UNKNOWN: {} error running nvme command: {}").format(
19+ device, error
20+ )
21+ unknown = True
22+ alloutputs.append(status)
23+ continue
24
25 for line in output.decode(errors="ignore").splitlines():
26 datavalues_re = re.match(r"^(\w+)\s+:\s+([\d.]+)", line.strip())
27@@ -70,6 +76,9 @@ def parse_output(warning_used, critical_used): # noqa: C901
28 if critical:
29 raise CriticalError("\n".join(alloutputs))
30
31+ if unknown:
32+ raise UnknownError("\n".join(alloutputs))
33+
34 if warning:
35 raise WarnError("\n".join(alloutputs))
36

Subscribers

No one subscribed via source and target branches