Ensure we clean up if an exception kills strategy.run. Fixes #23958 (#71513)

This commit is contained in:
Matt Martz 2020-09-03 14:09:08 -05:00 committed by GitHub
parent d398a4b4f0
commit 0cf4aabc55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -0,0 +1,3 @@
bugfixes:
- Ensure if a traceback halts ``strategy.run`` that we still attempt to clean up
(https://github.com/ansible/ansible/issues/23958)

View file

@ -289,14 +289,16 @@ class TaskQueueManager:
self._start_at_done = True
# and run the play using the strategy and cleanup on way out
play_return = strategy.run(iterator, play_context)
try:
play_return = strategy.run(iterator, play_context)
finally:
strategy.cleanup()
self._cleanup_processes()
# now re-save the hosts that failed from the iterator to our internal list
for host_name in iterator.get_failed_hosts():
self._failed_hosts[host_name] = True
strategy.cleanup()
self._cleanup_processes()
return play_return
def cleanup(self):