Clean up PlaybookExecutor logic for batches and errors

The calculation for max_fail_percentage was moved into the linear
strategy a while back, and works better there in the stategy layer
rather than at the PBE layer. This patch removes it from the PBE layer
and tweaks the logic controlling whether or not the next batch is run.

Fixes #15954

(cherry picked from commit 890e096b2b)
This commit is contained in:
James Cammarata 2016-08-18 13:52:34 -05:00
parent fc3efdb057
commit f80c981ef6

View file

@ -156,22 +156,19 @@ class PlaybookExecutor:
# batch failed # batch failed
failed_hosts_count = len(self._tqm._failed_hosts) + len(self._tqm._unreachable_hosts) - \ failed_hosts_count = len(self._tqm._failed_hosts) + len(self._tqm._unreachable_hosts) - \
(previously_failed + previously_unreachable) (previously_failed + previously_unreachable)
if new_play.max_fail_percentage is not None and \
int((new_play.max_fail_percentage)/100.0 * len(batch)) > int((len(batch) - failed_hosts_count) / len(batch) * 100.0): if len(batch) == failed_hosts_count:
break_play = True
break
elif len(batch) == failed_hosts_count:
break_play = True break_play = True
break break
# update the previous counts so they don't accumulate incorrectly
# over multiple serial batches
previously_failed += len(self._tqm._failed_hosts) - previously_failed
previously_unreachable += len(self._tqm._unreachable_hosts) - previously_unreachable
# save the unreachable hosts from this batch # save the unreachable hosts from this batch
self._unreachable_hosts.update(self._tqm._unreachable_hosts) self._unreachable_hosts.update(self._tqm._unreachable_hosts)
# if the last result wasn't zero or 3 (some hosts were unreachable),
# break out of the serial batch loop
if result not in (self._tqm.RUN_OK, self._tqm.RUN_UNREACHABLE_HOSTS):
break
if break_play: if break_play:
break break