diff options
author | Matt Clay <matt@mystile.com> | 2022-12-14 12:21:53 -0800 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2022-12-14 15:56:08 -0800 |
commit | e6ac16674cacaf5105d7027c69e10b3ebebb16c8 (patch) | |
tree | 300d963a52b4dc81162de02f1a182f740ee53486 | |
parent | 55a198da111a347ab2132bbcdb9a49cd65f2b704 (diff) | |
download | ansible-e6ac16674cacaf5105d7027c69e10b3ebebb16c8.tar.gz |
[stable-2.13] Add more retries to ansible-test-container test.
(cherry picked from commit f6c0e22f98e3ad1e0a98837053ed03a27d8a1fcf)
Co-authored-by: Matt Clay <matt@mystile.com>
-rwxr-xr-x | test/integration/targets/ansible-test-container/runme.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/test/integration/targets/ansible-test-container/runme.py b/test/integration/targets/ansible-test-container/runme.py index ca0ce86f93..52315a3bf3 100755 --- a/test/integration/targets/ansible-test-container/runme.py +++ b/test/integration/targets/ansible-test-container/runme.py @@ -256,7 +256,7 @@ def run_test(scenario: TestScenario) -> TestResult: try: if prime_storage_command: - retry_command(lambda: run_command(*prime_storage_command)) + retry_command(lambda: run_command(*prime_storage_command), retry_any_error=True) if scenario.disable_selinux: run_command('setenforce', 'permissive') @@ -278,7 +278,7 @@ def run_test(scenario: TestScenario) -> TestResult: cleanup_command = [scenario.engine, 'rmi', '-f', scenario.image] try: - retry_command(lambda: run_command(*client_become_cmd + [f'{format_env(common_env)}{shlex.join(cleanup_command)}'])) + retry_command(lambda: run_command(*client_become_cmd + [f'{format_env(common_env)}{shlex.join(cleanup_command)}']), retry_any_error=True) except SubprocessError as ex: display.error(str(ex)) @@ -679,7 +679,7 @@ def run_module( return run_command('ansible-playbook', '-v', playbook_file.name) -def retry_command(func: t.Callable[[], SubprocessResult], attempts: int = 3) -> SubprocessResult: +def retry_command(func: t.Callable[[], SubprocessResult], attempts: int = 3, retry_any_error: bool = False) -> SubprocessResult: """Run the given command function up to the specified number of attempts when the failure is due to an SSH error.""" for attempts_remaining in range(attempts - 1, -1, -1): try: @@ -693,6 +693,11 @@ def retry_command(func: t.Callable[[], SubprocessResult], attempts: int = 3) -> time.sleep(3) continue + if retry_any_error: + display.warning('Command failed. Waiting a few seconds before retrying.') + time.sleep(3) + continue + raise |