Break out of linear strategy if all hosts are failed and the result is not OK

Fixes #18021
pull/18055/head
James Cammarata 8 years ago
parent 5ece97ae5b
commit 5be2a3a9e0

@ -395,7 +395,8 @@ class StrategyModule(StrategyBase):
if any_errors_fatal and (len(failed_hosts) > 0 or len(unreachable_hosts) > 0): if any_errors_fatal and (len(failed_hosts) > 0 or len(unreachable_hosts) > 0):
for host in hosts_left: for host in hosts_left:
(s, _) = iterator.get_next_task_for_host(host, peek=True) (s, _) = iterator.get_next_task_for_host(host, peek=True)
if s.run_state != iterator.ITERATING_RESCUE: if s.run_state != iterator.ITERATING_RESCUE or \
s.run_state == iterator.ITERATING_RESCUE and s.fail_state & iterator.FAILED_RESCUE != 0:
self._tqm._failed_hosts[host.name] = True self._tqm._failed_hosts[host.name] = True
result |= self._tqm.RUN_FAILED_BREAK_PLAY result |= self._tqm.RUN_FAILED_BREAK_PLAY
display.debug("done checking for any_errors_fatal") display.debug("done checking for any_errors_fatal")
@ -415,6 +416,13 @@ class StrategyModule(StrategyBase):
result |= self._tqm.RUN_FAILED_BREAK_PLAY result |= self._tqm.RUN_FAILED_BREAK_PLAY
display.debug("done checking for max_fail_percentage") display.debug("done checking for max_fail_percentage")
display.debug("checking to see if all hosts have failed and the running result is not ok")
if result != self._tqm.RUN_OK and len(self._tqm._failed_hosts) >= len(hosts_left):
display.debug("^ not ok, so returning result now")
self._tqm.send_callback('v2_playbook_on_no_hosts_remaining')
return result
display.debug("done checking to see if all hosts have failed")
except (IOError, EOFError) as e: except (IOError, EOFError) as e:
display.debug("got IOError/EOFError in task loop: %s" % e) display.debug("got IOError/EOFError in task loop: %s" % e)
# most likely an abort, return failed # most likely an abort, return failed

Loading…
Cancel
Save