From f80c981ef6c315af78dc4d10413c730bef699491 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 18 Aug 2016 13:52:34 -0500 Subject: [PATCH] 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 890e096b2b3b9bf71d8ba85d92dc1419aa12477a) --- lib/ansible/executor/playbook_executor.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/ansible/executor/playbook_executor.py b/lib/ansible/executor/playbook_executor.py index fe0f76dd6fc..12a9e09260d 100644 --- a/lib/ansible/executor/playbook_executor.py +++ b/lib/ansible/executor/playbook_executor.py @@ -156,22 +156,19 @@ class PlaybookExecutor: # batch failed failed_hosts_count = len(self._tqm._failed_hosts) + len(self._tqm._unreachable_hosts) - \ (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): - break_play = True - break - elif len(batch) == failed_hosts_count: + + if len(batch) == failed_hosts_count: break_play = True 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 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: break