summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2022-12-14 12:21:53 -0800
committerMatt Clay <matt@mystile.com>2022-12-14 14:50:59 -0800
commitf6c0e22f98e3ad1e0a98837053ed03a27d8a1fcf (patch)
treeb9581d35a3a3a3ce90d003c5129ceda189e020bb
parent75b60b17ee1ff18ded04cf07b71e4ee32e673a0b (diff)
downloadansible-f6c0e22f98e3ad1e0a98837053ed03a27d8a1fcf.tar.gz
Add more retries to ansible-test-container test.
-rwxr-xr-xtest/integration/targets/ansible-test-container/runme.py11
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 1577b62286..d91cf9333d 100755
--- a/test/integration/targets/ansible-test-container/runme.py
+++ b/test/integration/targets/ansible-test-container/runme.py
@@ -255,7 +255,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')
@@ -277,7 +277,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))
@@ -667,7 +667,7 @@ def run_module(
return run_command('ansible', '-m', module, '-v', '-a', json.dumps(args), 'localhost')
-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:
@@ -681,6 +681,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