diff options
author | Martin Krizek <martin.krizek@gmail.com> | 2023-01-18 23:22:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-18 16:22:34 -0600 |
commit | c297ee9b5da91a0054feb2ea6fd971e21e22d4f5 (patch) | |
tree | 96b11ed5f318d3f7f83447ab435d605b32419ad4 /lib | |
parent | 3a21caa2179437aecd5455c91f9dec88c19653a5 (diff) | |
download | ansible-c297ee9b5da91a0054feb2ea6fd971e21e22d4f5.tar.gz |
Correctly count rescued tasks in play stats (#79724) (#79728)
Fixes #79711
ci_complete
(cherry picked from commit e38b3e64fd5f9bb6c5ca9462150c89f0932fd2c4)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ansible/executor/play_iterator.py | 2 | ||||
-rw-r--r-- | lib/ansible/plugins/strategy/__init__.py | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/ansible/executor/play_iterator.py b/lib/ansible/executor/play_iterator.py index 6049b236f1..2449782165 100644 --- a/lib/ansible/executor/play_iterator.py +++ b/lib/ansible/executor/play_iterator.py @@ -571,7 +571,7 @@ class PlayIterator: Given the current HostState state, determines if the current block, or any child blocks, are in rescue mode. ''' - if state.get_current_block().rescue: + if state.run_state == IteratingStates.TASKS and state.get_current_block().rescue: return True if state.tasks_child_state is not None: return self.is_any_block_rescuing(state.tasks_child_state) diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 2f04a3f73f..e3c4b02da6 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -551,6 +551,8 @@ class StrategyBase: role_ran = True ignore_errors = original_task.ignore_errors if not ignore_errors: + # save the current state before failing it for later inspection + state_when_failed = iterator.get_state_for_host(original_host.name) display.debug("marking %s as failed" % original_host.name) if original_task.run_once: # if we're using run_once, we have to fail every host here @@ -568,7 +570,7 @@ class StrategyBase: # if we're iterating on the rescue portion of a block then # we save the failed task in a special var for use # within the rescue/always - if iterator.is_any_block_rescuing(state): + if iterator.is_any_block_rescuing(state_when_failed): self._tqm._stats.increment('rescued', original_host.name) iterator._play._removed_hosts.remove(original_host.name) self._variable_manager.set_nonpersistent_facts( |