Merge ~vern/charm-hw-health:check_megacli_fix into charm-hw-health:master

Proposed by Vern Hart
Status: Merged
Approved by: Paul Goins
Approved revision: 73bc36af4260fe931267968ac427dbfe93f35e64
Merged at revision: a51a6cba0c3cca4c663e40030fe040e56fa005c6
Proposed branch: ~vern/charm-hw-health:check_megacli_fix
Merge into: charm-hw-health:master
Diff against target: 19 lines (+5/-2)
1 file modified
src/files/megacli/check_megacli.py (+5/-2)
Reviewer Review Type Date Requested Status
Garrett Neugent (community) Approve
Paul Goins Approve
BootStack Reviewers Pending
Review via email: mp+424914@code.launchpad.net

Commit message

Properly handle return code of megacli cronjob Fixes LP: #1978896

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
Paul Goins (vultaire) wrote :

This is an unfortunate bug. It's one of the checks that we struggle to test since we don't have the target hardware, but this type of bug kind of begs for a unit test which mocks that out to a basic level.

The fix looks exactly like what we need. +1.

review: Approve
Revision history for this message
Garrett Neugent (thogarre) wrote :

Thanks for catching this Vern, and for fixing it proactively! +1 from me as well

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision a51a6cba0c3cca4c663e40030fe040e56fa005c6

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/files/megacli/check_megacli.py b/src/files/megacli/check_megacli.py
2index be8c065..dc09607 100755
3--- a/src/files/megacli/check_megacli.py
4+++ b/src/files/megacli/check_megacli.py
5@@ -61,9 +61,12 @@ def handle_results(nlines, match, critical, errors, num_ldrive, num_pdrive, poli
6 def check_cron_return_code(rc_file=RC_FILE):
7 with open(rc_file) as return_code_file:
8 rc = return_code_file.read().strip()
9- if rc != 0:
10+ try:
11+ rc = int(rc)
12+ if rc != 0: raise ValueError()
13+ except ValueError as e:
14 msg = "WARNING: megacli cron job failed, return code {}".format(rc)
15- raise WarnError(msg)
16+ raise WarnError(msg) from None
17
18
19 def parse_output(policy=False): # noqa:C901

Subscribers

People subscribed via source and target branches

to all changes: