summaryrefslogtreecommitdiff
path: root/zuul/ansible
diff options
context:
space:
mode:
authorIan Wienand <iwienand@redhat.com>2022-04-21 18:23:57 +1000
committerIan Wienand <iwienand@redhat.com>2022-04-28 09:55:24 +1000
commitbc45371fdd964c604c5cb2b158643f7e4c297d13 (patch)
treeb48dbcc351c44fef4142b29aa3bb07ec373b0a7c /zuul/ansible
parent8582dac3ade1959c39510449b2872590a4d5b654 (diff)
downloadzuul-bc45371fdd964c604c5cb2b158643f7e4c297d13.tar.gz
ansible zuul_json callback : handle string results
We have noted a problem with tasks such as "yum:" or "package:" that output is not being logged in the job json file. After investigation, I have found that this is failing with an exception in the results parsing at for index, item_result in enumerate( clean_result.get('results', [])): if not item_result.get('_ansible_no_log', False): continue When we are *not* processing a task loop, "results" is a simple list of strings about the package results; thus when it walks each result the "item_result.get('_ansible_no_log', False)" step fails because a string has no ".get()". This causes the plugin to exit and the information in the resulting .json to be incomplete, leading to the tasks being missing from the UI. I believe this was a regression introduced with I9e8d08f75207b362ca23457c44cc2f38ff43ac23. When we *are* processing a task loop, "results" is a list where each entry is a loop-item result. In this case, we are always walking a list of dictionaries, so the existing ".get()" call works. Change-Id: I02bcd307bcfad8d99dd0db13d979ce7ba3d5e0e4
Diffstat (limited to 'zuul/ansible')
-rw-r--r--zuul/ansible/base/callback/zuul_json.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/zuul/ansible/base/callback/zuul_json.py b/zuul/ansible/base/callback/zuul_json.py
index 1d7059871..d8ff5f3fe 100644
--- a/zuul/ansible/base/callback/zuul_json.py
+++ b/zuul/ansible/base/callback/zuul_json.py
@@ -148,6 +148,15 @@ class CallbackModule(CallbackBase):
for index, item_result in enumerate(
clean_result.get('results', [])):
+ # If in a loop, this will be a list of result
+ # dictionaries. Otherwise for other tasks
+ # (yum/package are examples) each entry is a string.
+ if not hasattr(item_result, 'get'):
+ continue
+ # NOTE(ianw) 2022-04-21 : it is not entirely clear if
+ # results having _ansible_no_log here has actually
+ # been fixed upstream. For an abundance of caution,
+ # leave this.
if not item_result.get('_ansible_no_log', False):
continue
clean_result['results'][index] = dict(