Ensure has_dead_workers functions (#60653)

* Ensure has_dead_workers functions

* Fix up tests

* Add changelog. Fixes #29124
This commit is contained in:
Matt Martz 2019-08-22 14:32:49 -05:00 committed by GitHub
parent 5b16e012a4
commit 0ff9978bc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 5 deletions

View file

@ -0,0 +1,4 @@
bugfixes:
- TaskQueueManager - Ensure ``has_dead_workers`` can function, by using the
correct reference, and only allow an exit code of 0.
(https://github.com/ansible/ansible/issues/29124)

View file

@ -286,10 +286,9 @@ class TaskQueueManager:
# <WorkerProcess(WorkerProcess-2, stopped[SIGTERM])>
defunct = False
for (idx, x) in enumerate(self._workers):
if hasattr(x, 'exitcode'):
if x.exitcode in [-9, -11, -15]:
defunct = True
for x in self._workers:
if getattr(x, 'exitcode', None):
defunct = True
return defunct
def send_callback(self, method_name, *args, **kwargs):

View file

@ -158,7 +158,7 @@ class StrategyBase:
def __init__(self, tqm):
self._tqm = tqm
self._inventory = tqm.get_inventory()
self._workers = tqm.get_workers()
self._workers = tqm._workers
self._variable_manager = tqm.get_variable_manager()
self._loader = tqm.get_loader()
self._final_q = tqm._final_q

View file

@ -64,6 +64,7 @@ class TestStrategyBase(unittest.TestCase):
mock_tqm = MagicMock(TaskQueueManager)
mock_tqm._final_q = mock_queue
mock_tqm._workers = []
strategy_base = StrategyBase(tqm=mock_tqm)
strategy_base.cleanup()
@ -103,6 +104,7 @@ class TestStrategyBase(unittest.TestCase):
mock_tqm._failed_hosts = dict()
mock_tqm._unreachable_hosts = dict()
mock_tqm._workers = []
strategy_base = StrategyBase(tqm=mock_tqm)
mock_host = MagicMock()