Skip to content

Commit

Permalink
Fix none result as failed (#4)
Browse files Browse the repository at this point in the history
only handle false result as failure
  • Loading branch information
nicholasmhughes committed Mar 18, 2022
1 parent 10764fb commit 7b29fe4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog/3.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix textfile output to view None result as success
8 changes: 4 additions & 4 deletions src/saltext/prometheus/returners/prometheus_textfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ def returner(ret):
for data in ret.get("return", {}).values():
total += 1
duration += data.get("duration", 0)
if data["result"]:
success += 1
else:
if data["result"] is False:
failure += 1
else:
success += 1
if data.get("changes"):
changed += 1

Expand Down Expand Up @@ -331,7 +331,7 @@ def returner(ret):

if opts["show_failed_states"]:
for state_id, state_return in ret["return"].items():
if not state_return["result"]:
if state_return["result"] is False:
key = (
'salt_failed{state_id="'
+ state_id.split("_|-")[1]
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/returners/test_prometheus_textfile_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def job_ret():
"stdout": "applyme",
"stderr": "",
},
"result": True,
"result": None,
"comment": 'Command "echo applyme" run',
"__sls__": "applyme",
"__run_num__": 1,
Expand Down

0 comments on commit 7b29fe4

Please sign in to comment.