Skip to content

Commit

Permalink
differentiate timeout vs idle timeout
Browse files Browse the repository at this point in the history
currently idle timeout and timeout result in the same status call back this result in the AWX not being able to parse the differences between the two failure condition and make it confusing to debg

Co-Authored-By: Gabriel Muniz <[email protected]>
  • Loading branch information
TheRealHaoLiu and Gabriel Muniz committed Feb 28, 2023
1 parent a4a981d commit d392c51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ansible_runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, config, cancel_callback=None, remove_partials=True, event_han
self.status_handler = status_handler
self.canceled = False
self.timed_out = False
self.idle_timed_out = False
self.errored = False
self.status = "unstarted"
self.rc = None
Expand Down Expand Up @@ -337,7 +338,7 @@ def _decode(x):
if self.config.idle_timeout and (time.time() - self.last_stdout_update) > self.config.idle_timeout:
self.kill_container()
Runner.handle_termination(child.pid, is_cancel=False)
self.timed_out = True
self.idle_timed_out = True

stdout_handle.close()
stderr_handle.close()
Expand All @@ -350,6 +351,8 @@ def _decode(x):
self.status_callback('successful')
elif self.timed_out:
self.status_callback('timeout')
elif self.idle_timed_out:
self.status_callback('idle_timeout')
else:
self.status_callback('failed')

Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_run_command_idle_timeout(rc):
rc.idle_timeout = 0.0000001
runner = Runner(config=rc)
status, exitcode = runner.run()
assert status == 'timeout'
assert status == 'idle_timeout'
assert exitcode == 254


Expand Down

0 comments on commit d392c51

Please sign in to comment.