mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 22:33:25 +00:00
Tweak how strategies evaluate failed hosts via the iterator and bug fixes
* Added additional methods to the iterator code to assess host failures while also taking into account the block rescue/always states * Fixed bugs in the free strategy, where results were not always being processed after being collected * Added some prettier printing to the state output from iterator Fixes #13699
This commit is contained in:
@@ -78,7 +78,7 @@ class StrategyModule(StrategyBase):
|
||||
(state, task) = iterator.get_next_task_for_host(host, peek=True)
|
||||
display.debug("free host state: %s" % state)
|
||||
display.debug("free host task: %s" % task)
|
||||
if host_name not in self._tqm._failed_hosts and host_name not in self._tqm._unreachable_hosts and task:
|
||||
if not iterator.is_failed(host) and host_name not in self._tqm._unreachable_hosts and task:
|
||||
|
||||
# set the flag so the outer loop knows we've still found
|
||||
# some work which needs to be done
|
||||
@@ -135,7 +135,7 @@ class StrategyModule(StrategyBase):
|
||||
if last_host == starting_host:
|
||||
break
|
||||
|
||||
results = self._process_pending_results(iterator)
|
||||
results = self._wait_on_pending_results(iterator)
|
||||
host_results.extend(results)
|
||||
|
||||
try:
|
||||
@@ -176,13 +176,7 @@ class StrategyModule(StrategyBase):
|
||||
display.debug("done adding collected blocks to iterator")
|
||||
|
||||
# pause briefly so we don't spin lock
|
||||
time.sleep(0.05)
|
||||
|
||||
try:
|
||||
results = self._wait_on_pending_results(iterator)
|
||||
host_results.extend(results)
|
||||
except Exception as e:
|
||||
pass
|
||||
time.sleep(0.001)
|
||||
|
||||
# run the base class run() method, which executes the cleanup function
|
||||
# and runs any outstanding handlers which have been triggered
|
||||
|
||||
@@ -54,7 +54,8 @@ class StrategyModule(StrategyBase):
|
||||
host_tasks = {}
|
||||
display.debug("building list of next tasks for hosts")
|
||||
for host in hosts:
|
||||
host_tasks[host.name] = iterator.get_next_task_for_host(host, peek=True)
|
||||
if not iterator.is_failed(host):
|
||||
host_tasks[host.name] = iterator.get_next_task_for_host(host, peek=True)
|
||||
display.debug("done building task lists")
|
||||
|
||||
num_setups = 0
|
||||
@@ -98,7 +99,7 @@ class StrategyModule(StrategyBase):
|
||||
rvals = []
|
||||
display.debug("starting to advance hosts")
|
||||
for host in hosts:
|
||||
host_state_task = host_tasks[host.name]
|
||||
host_state_task = host_tasks.get(host.name)
|
||||
if host_state_task is None:
|
||||
continue
|
||||
(s, t) = host_state_task
|
||||
|
||||
Reference in New Issue
Block a user