Skip to content

Commit

Permalink
Update PV reclaim policy from Retain to Delete in pvc_factory_fixture…
Browse files Browse the repository at this point in the history
… finalizer to ensure that PVs are deleted along with backend images and subvolumes.

Signed-off-by: Sidhant Agrawal <[email protected]>
  • Loading branch information
sidhant-agrawal committed Nov 9, 2023
1 parent bb38bf3 commit 7366f55
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,18 +1112,18 @@ def finalizer():
instance.ocp.wait_for_delete(instance.name)

# Wait for PVs to delete
# If they have ReclaimPolicy set to Retain then delete them manually
# If they have ReclaimPolicy set to Retain then change to Delete
for pv_obj in pv_objs:
if (
pv_obj.data.get("spec", {}).get("persistentVolumeReclaimPolicy")
== constants.RECLAIM_POLICY_RETAIN
and pv_obj is not None
):
helpers.wait_for_resource_state(pv_obj, constants.STATUS_RELEASED)
pv_obj.delete()
pv_obj.ocp.wait_for_delete(pv_obj.name)
else:
pv_obj.ocp.wait_for_delete(resource_name=pv_obj.name, timeout=180)
patch_param = '{"spec":{"persistentVolumeReclaimPolicy":"Delete"}}'
pv_obj.ocp.patch(resource_name=pv_obj.name, params=patch_param)

pv_obj.ocp.wait_for_delete(resource_name=pv_obj.name, timeout=180)

request.addfinalizer(finalizer)
return factory
Expand Down

0 comments on commit 7366f55

Please sign in to comment.