summaryrefslogtreecommitdiff
path: root/zuul/ansible
diff options
context:
space:
mode:
authorIan Wienand <iwienand@redhat.com>2022-04-28 09:55:06 +1000
committerIan Wienand <iwienand@redhat.com>2022-04-28 09:57:14 +1000
commit7996f634fa3626530034214cfab5d63e2c431fb9 (patch)
treeb69736945cc8601d62677fa291f065f6d6da242e /zuul/ansible
parent4e89ea4e18d867d5409da31e108a61ce627f757d (diff)
downloadzuul-7996f634fa3626530034214cfab5d63e2c431fb9.tar.gz
zuul_json: remove no_log handling
The current no_log handling here was added in the following steps Ic1becaf2f3ab345da22fa62314f1296d76777fec was the original zuul_json and added the check of the result object if result._result.get('_ansible_no_log', False): This happened in July, 2017. However, soon after in October 2017, Ansible merged [1] which changed things so that the callbacks (v2_runner_on_ok) get "clean copy" of the TaskResult object; e.g. if isinstance(arg, TaskResult): new_args.append(arg.clean_copy()) It can be seen at [2] that this is where results are censored. This change made it into Ansible 2.5. Ergo this callback will never see uncensored results here. The second part of the no_log processing here was added with I9e8d08f75207b362ca23457c44cc2f38ff43ac23 in March 2018. This was to work around an issue with loops, where the uncensored values would "leak" into the results under certain circumstances when using loops, e.g. - name: A templated no_log loop a_task: a_arg: 'foo' no_log: '{{ item }}' loop: - True - False Ansible merged a few changes related to fixing this. [3] was merged in June 2018 for this exact issue of unreachable hosts. [4] was merged in August 2018, which makes it so that if any loop item is "no_log", the whole task is. Both of these changes made it into Ansible 2.7. Ansible has merged test-cases for these, but we have also merged test-cases, so we have double coverage against regression in the future. Ergo, I believe we can revert both of these checks. This also means we don't have to worry about special-casing string results as done in I02bcd307bcfad8d99dd0db13d979ce7ba3d5e0e4. [1] https://github.com/ansible/ansible/commit/01b6c7c9c6b7459a3cb53ffc2fe02a8dcc1a3acc [2] https://github.com/ansible/ansible/blob/f7c2b1986c5b6afce1d8fe83ce6bf26b535aa617/lib/ansible/executor/task_result.py#L13 [3] https://github.com/ansible/ansible/commit/336b3762b23a64e355cfa3efba11ddf5bdd7f0d8 [4] https://github.com/ansible/ansible/commit/bda074d34e46ee9862a48ed067ad42260d3f92ab Change-Id: I00ef08869f3a8f08a1affa5e15e3386a1891f11e
Diffstat (limited to 'zuul/ansible')
-rw-r--r--zuul/ansible/base/callback/zuul_json.py35
1 files changed, 6 insertions, 29 deletions
diff --git a/zuul/ansible/base/callback/zuul_json.py b/zuul/ansible/base/callback/zuul_json.py
index d8ff5f3fe..aff9ad2e2 100644
--- a/zuul/ansible/base/callback/zuul_json.py
+++ b/zuul/ansible/base/callback/zuul_json.py
@@ -135,35 +135,12 @@ class CallbackModule(CallbackBase):
def v2_runner_on_ok(self, result, **kwargs):
host = result._host
action = result._task.action
- if result._result.get('_ansible_no_log', False) or result._task.no_log:
- self.results[-1]['tasks'][-1]['hosts'][host.name] = dict(
- censored="the output has been hidden due to the fact that"
- " 'no_log: true' was specified for this result")
- else:
- # strip_internal_keys makes a deep copy of dict items, but
- # not lists, so we need to create our own complete deep
- # copy first so we don't modify the original.
- myresult = copy.deepcopy(result._result)
- clean_result = strip_internal_keys(myresult)
-
- 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(
- censored="the output has been hidden due to the fact that"
- " 'no_log: true' was specified for this result")
-
- self.results[-1]['tasks'][-1]['hosts'][host.name] = clean_result
+ # strip_internal_keys makes a deep copy of dict items, but
+ # not lists, so we need to create our own complete deep
+ # copy first so we don't modify the original.
+ myresult = copy.deepcopy(result._result)
+ clean_result = strip_internal_keys(myresult)
+ self.results[-1]['tasks'][-1]['hosts'][host.name] = clean_result
end_time = current_time()
self.results[-1]['tasks'][-1]['task']['duration']['end'] = end_time
self.results[-1]['play']['duration']['end'] = end_time