Ensure has_dead_workers functions (#60653)
* Ensure has_dead_workers functions * Fix up tests * Add changelog. Fixes #29124
This commit is contained in:
parent
5b16e012a4
commit
0ff9978bc5
4 changed files with 10 additions and 5 deletions
4
changelogs/fragments/29124-has-dead-workers.yaml
Normal file
4
changelogs/fragments/29124-has-dead-workers.yaml
Normal 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)
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue