Skip to content

Commit

Permalink
Set failed check executions as critical (#43)
Browse files Browse the repository at this point in the history
* Disable check result overwritting

* Set abnormally failed tasks to critical

* Update python binary path in Dockerfile
  • Loading branch information
arbulu89 authored Apr 27, 2022
1 parent ba85dba commit c7a27b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ADD . /build
RUN zypper -n in git-core && make build

FROM registry.suse.com/bci/python:3.9 AS trento-runner
RUN /usr/bin/python3 -m venv /venv \
RUN /usr/local/bin/python3 -m venv /venv \
&& /venv/bin/pip install 'ansible~=4.6.0' 'requests~=2.26.0' 'rpm==0.0.2' 'pyparsing~=2.0' \
&& zypper -n ref && zypper -n in --no-recommends openssh \
&& zypper -n clean
Expand Down
8 changes: 5 additions & 3 deletions runner/ansible/callback_plugins/trento.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ def add_result(self, check_id, result, msg=""):
"""
Add check result
"""
# Check if a result already exists
# Due how ansible callbacks system works, we might get same check results twice
# where the 2nd result is false, as it gives the results of `set_test_result` task
# when the check has failed due abnormal behaviours
for result_item in self.results:
if result_item.check_id == check_id:
result_item.result = result
result_item.msg = msg
break
else:
self.results.append(CheckResult(check_id, result, msg))
Expand Down Expand Up @@ -241,7 +243,7 @@ def v2_runner_on_failed(self, result, ignore_errors):

msg = result._check_key("msg")
self.execution_results.add_host(host, True)
self.execution_results.add_result(host, task_vars[CHECK_ID], "warning", msg)
self.execution_results.add_result(host, task_vars[CHECK_ID], "critical", msg)

def v2_runner_on_skipped(self, result):
"""
Expand Down

0 comments on commit c7a27b7

Please sign in to comment.