Skip to content

Commit c2a84df

Browse files
committed
Fix DataImportCron test failures by properly waiting for VolumeSnapshot readiness using volume_snapshot.wait().
1 parent df6736d commit c2a84df

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

utilities/storage.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,16 +1010,27 @@ def verify_dv_and_pvc_does_not_exist(name, namespace, timeout=TIMEOUT_10MIN):
10101010

10111011

10121012
def wait_for_volume_snapshot_ready_to_use(namespace, name):
1013+
"""Wait until the specified VolumeSnapshot exists and is ready to use.
1014+
1015+
Args:
1016+
namespace (str): Namespace name.
1017+
name (str): The name of the VolumeSnapshot to wait for.
1018+
1019+
Raises:
1020+
TimeoutError: If the VolumeSnapshot does not reach `readyToUse` within the timeout period.
1021+
"""
10131022
ready_to_use_status = "readyToUse"
10141023
LOGGER.info(f"Wait for VolumeSnapshot '{name}' in '{namespace}' to be '{ready_to_use_status}'")
10151024
volume_snapshot = VolumeSnapshot(namespace=namespace, name=name)
1025+
volume_snapshot.wait()
10161026
try:
10171027
for sample in TimeoutSampler(
10181028
wait_timeout=TIMEOUT_5MIN,
10191029
sleep=TIMEOUT_5SEC,
10201030
func=lambda: volume_snapshot.instance.get("status", {}).get(ready_to_use_status) is True,
10211031
):
10221032
if sample:
1033+
LOGGER.info(f"VolumeSnapshot '{name}' in namespace '{namespace}' reached '{ready_to_use_status}'")
10231034
return volume_snapshot
10241035
except TimeoutExpiredError:
10251036
fail_msg = f"failed to reach {ready_to_use_status} status" if volume_snapshot.exists else "failed to create"

0 commit comments

Comments
 (0)