diff options
-rw-r--r-- | changelogs/fragments/timeout_show_frame.yml | 2 | ||||
-rw-r--r-- | lib/ansible/executor/task_executor.py | 8 | ||||
-rw-r--r-- | test/integration/targets/playbook/timeout.yml | 1 |
3 files changed, 8 insertions, 3 deletions
diff --git a/changelogs/fragments/timeout_show_frame.yml b/changelogs/fragments/timeout_show_frame.yml new file mode 100644 index 0000000000..fcdb61beef --- /dev/null +++ b/changelogs/fragments/timeout_show_frame.yml @@ -0,0 +1,2 @@ +minor_changes: + - task timeout now returns timedout key with frame/code that was in execution when the timeout is triggered. diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index b65dc420cc..af203e008b 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -42,11 +42,13 @@ __all__ = ['TaskExecutor'] class TaskTimeoutError(BaseException): - pass + def __init__(self, message="", frame=None): + self.frame = str(frame) + super(TaskTimeoutError, self).__init__(message) def task_timeout(signum, frame): - raise TaskTimeoutError + raise TaskTimeoutError(frame=frame) def remove_omit(task_args, omit_token): @@ -640,7 +642,7 @@ class TaskExecutor: return dict(unreachable=True, msg=to_text(e)) except TaskTimeoutError as e: msg = 'The %s action failed to execute in the expected time frame (%d) and was terminated' % (self._task.action, self._task.timeout) - return dict(failed=True, msg=msg) + return dict(failed=True, msg=msg, timedout=e.frame) finally: if self._task.timeout: signal.alarm(0) diff --git a/test/integration/targets/playbook/timeout.yml b/test/integration/targets/playbook/timeout.yml index 442e13aed5..c0a76265fe 100644 --- a/test/integration/targets/playbook/timeout.yml +++ b/test/integration/targets/playbook/timeout.yml @@ -10,3 +10,4 @@ that: - time is failed - '"The shell action failed to execute in the expected time frame" in time["msg"]' + - '"timedout" in time' |