mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Stash post-validated fields of the task in the TaskResult
This allows us to have a snapshot of the fields, which we can restore on the pre-fork side so as to avoid having to re-template fields.
This commit is contained in:
@@ -115,7 +115,12 @@ class WorkerProcess(multiprocessing.Process):
|
||||
display.debug("done running TaskExecutor() for %s/%s" % (self._host, self._task))
|
||||
self._host.vars = dict()
|
||||
self._host.groups = []
|
||||
task_result = TaskResult(self._host.name, self._task._uuid, executor_result)
|
||||
task_result = TaskResult(
|
||||
self._host.name,
|
||||
self._task._uuid,
|
||||
executor_result,
|
||||
task_fields=self._task.dump_attrs(),
|
||||
)
|
||||
|
||||
# put the result on the result queue
|
||||
display.debug("sending task result")
|
||||
@@ -125,7 +130,12 @@ class WorkerProcess(multiprocessing.Process):
|
||||
except AnsibleConnectionFailure:
|
||||
self._host.vars = dict()
|
||||
self._host.groups = []
|
||||
task_result = TaskResult(self._host.name, self._task._uuid, dict(unreachable=True))
|
||||
task_result = TaskResult(
|
||||
self._host.name,
|
||||
self._task._uuid,
|
||||
dict(unreachable=True),
|
||||
task_fields=self._task.dump_attrs(),
|
||||
)
|
||||
self._rslt_q.put(task_result, block=False)
|
||||
|
||||
except Exception as e:
|
||||
@@ -133,7 +143,12 @@ class WorkerProcess(multiprocessing.Process):
|
||||
try:
|
||||
self._host.vars = dict()
|
||||
self._host.groups = []
|
||||
task_result = TaskResult(self._host.name, self._task._uuid, dict(failed=True, exception=to_text(traceback.format_exc()), stdout=''))
|
||||
task_result = TaskResult(
|
||||
self._host.name,
|
||||
self._task._uuid,
|
||||
dict(failed=True, exception=to_text(traceback.format_exc()), stdout=''),
|
||||
task_fields=self._task.dump_attrs(),
|
||||
)
|
||||
self._rslt_q.put(task_result, block=False)
|
||||
except:
|
||||
display.debug(u"WORKER EXCEPTION: %s" % to_text(e))
|
||||
|
||||
Reference in New Issue
Block a user