Skip to content

Commit

Permalink
test: fix flaky test case test_volume_reattach_after_engine_sigkill
Browse files Browse the repository at this point in the history
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 <yang.chiu@suse.com>
  • Loading branch information
yangchiu authored and David Ko committed Jan 3, 2024
1 parent 6ece0d7 commit 2832bb3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions manager/integration/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2832bb3

Please sign in to comment.