From 2832bb344cfd0fae2ba226653f086ae8eba4c092 Mon Sep 17 00:00:00 2001 From: Yang Chiu Date: Mon, 1 Jan 2024 14:26:35 +0800 Subject: [PATCH] test: fix flaky test case test_volume_reattach_after_engine_sigkill the pod we're waiting could be terminated and recreated, so reading the pod could raise not found exception. wrapping it in try/except to make the waiting can continue. Signed-off-by: Yang Chiu --- manager/integration/tests/common.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/manager/integration/tests/common.py b/manager/integration/tests/common.py index c9ab1436dc..55cc55fc36 100644 --- a/manager/integration/tests/common.py +++ b/manager/integration/tests/common.py @@ -5000,11 +5000,14 @@ def wait_for_pod_restart(core_api, pod_name, namespace="default"): def wait_for_pod_phase(core_api, pod_name, pod_phase, namespace="default"): is_phase = False for _ in range(RETRY_COUNTS): - pod = core_api.read_namespaced_pod(name=pod_name, - namespace=namespace) - if pod.status.phase == pod_phase: - is_phase = True - break + try: + pod = core_api.read_namespaced_pod(name=pod_name, + namespace=namespace) + if pod.status.phase == pod_phase: + is_phase = True + break + except Exception as e: + print(f"Waiting for pod {pod_name} {pod_phase} failed: {e}") time.sleep(RETRY_INTERVAL_LONG) assert is_phase