summaryrefslogtreecommitdiff
path: root/zuul/ansible
diff options
context:
space:
mode:
authorIan Wienand <iwienand@redhat.com>2022-08-24 07:24:55 +1000
committerIan Wienand <iwienand@redhat.com>2022-08-24 13:29:45 +1000
commit98296dd5f6e27993f8ccd85dc439d3a54f66a112 (patch)
tree8c0c35925d8ca6d67068fb99b4da80742e2b097e /zuul/ansible
parent619999b6db425e4710a56db6d174e6df0c6c1a34 (diff)
downloadzuul-98296dd5f6e27993f8ccd85dc439d3a54f66a112.tar.gz
zuul_stream: handle failed_when tasks
Currently the task in the test playbook - hosts: compute1 tasks: - name: Command Not Found command: command-not-found failed_when: false is failing in the zuul_stream callback with an exception trying to fill out the "delta" value in the message here. The result dict (taken from the new output) shows us why: 2022-08-24 07:19:27.079961 | TASK [Command Not Found] 2022-08-24 07:19:28.578380 | compute1 | ok: ERROR (ignored) 2022-08-24 07:19:28.578622 | compute1 | { 2022-08-24 07:19:28.578672 | compute1 | "failed_when_result": false, 2022-08-24 07:19:28.578700 | compute1 | "msg": "[Errno 2] No such file or directory: b'command-not-found'", 2022-08-24 07:19:28.578726 | compute1 | "rc": 2 2022-08-24 07:19:28.578750 | compute1 | } i.e. it has no start/stop/delta in the result (it did run and fail, so you'd think it might ... but this is what Ansible gives us). This checks for this path; as mentioned the output will now look like above in this case. This was found by the prior change I9f569a411729f8a067de17d99ef6b9d74fc21543. This fixes the current warning, so we invert the test to prevent further regressions. Change-Id: I106b2bbe626ed5af8ca739d354ba41eca2f08f77
Diffstat (limited to 'zuul/ansible')
-rw-r--r--zuul/ansible/base/callback/zuul_stream.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/zuul/ansible/base/callback/zuul_stream.py b/zuul/ansible/base/callback/zuul_stream.py
index f31983ed6..966d7d6fa 100644
--- a/zuul/ansible/base/callback/zuul_stream.py
+++ b/zuul/ansible/base/callback/zuul_stream.py
@@ -535,10 +535,18 @@ class CallbackModule(default.CallbackModule):
elif result_dict.get('msg') == 'All items completed':
self._log_message(result, result_dict['msg'])
else:
- self._log_message(
- result,
- "Runtime: {delta}".format(
- **result_dict))
+ if 'delta' in result_dict:
+ self._log_message(
+ result,
+ "Runtime: {delta}".format(
+ **result_dict))
+ else:
+ # NOTE(ianw) 2022-08-24 : *Fairly* sure that you only
+ # fall into here when the call actually fails (and has
+ # not start/end time), but it is ignored by
+ # failed_when matching.
+ self._log_message(result, msg='ERROR (ignored)',
+ result_dict=result_dict)
def v2_runner_item_on_ok(self, result):
result_dict = dict(result._result)