diff --git a/python/tests/kubeutils.py b/python/tests/kubeutils.py index 6257ca812b..008c36ea1c 100644 --- a/python/tests/kubeutils.py +++ b/python/tests/kubeutils.py @@ -1,8 +1,8 @@ import tempfile -from runutils import run_and_assert +from runutils import run_with_retry -def meta_action_kube_artifacts(namespace, artifacts, action): +def meta_action_kube_artifacts(namespace, artifacts, action, retries=0): temp_file = tempfile.NamedTemporaryFile() temp_file.write(artifacts.encode()) temp_file.flush() @@ -14,12 +14,12 @@ def meta_action_kube_artifacts(namespace, artifacts, action): if namespace is not None: command.extend(['-n', namespace]) - run_and_assert(command) + run_with_retry(command, retries=retries) temp_file.close() def apply_kube_artifacts(namespace, artifacts): - meta_action_kube_artifacts(namespace=namespace, artifacts=artifacts, action='apply') + meta_action_kube_artifacts(namespace=namespace, artifacts=artifacts, action='apply', retries=1) def delete_kube_artifacts(namespace, artifacts): diff --git a/python/tests/runutils.py b/python/tests/runutils.py index 310543a79f..923d3d5769 100644 --- a/python/tests/runutils.py +++ b/python/tests/runutils.py @@ -12,12 +12,13 @@ def run_and_assert(command, communicate=True): return stdout.decode("utf-8") if stdout is not None else None return None -def run_with_retry(command): +def run_with_retry(command, retries=0): print(f"Running command {command}") returncode = -1 decoded = "" tries = 0 - while returncode != 0 and tries < 3: + max_tries = retries + 1 + while returncode != 0 and tries < max_tries: output = subprocess.Popen(command, stdout=subprocess.PIPE) if tries > 0: print('SLEEPING 5 seconds, TRIES=%d' % tries)