mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
e2e: remove claimRef after deleting the PVC
Instead of patching the PV to update the persistentVolumeReclaimPolicy and the claimRef before deleting the PVC. Patch PV persistentVolumeReclaimPolicy to Retain to retain the PV after deleting the PVC. Remove the claimRef on the PV after deleting the PVC so that claim can be attached to a new PVC. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
784b086ea5
commit
2205145654
18
e2e/rbd.go
18
e2e/rbd.go
@ -525,7 +525,8 @@ var _ = Describe("RBD", func() {
|
||||
e2elog.Logf("pv name is empty %q in namespace %q: %v", pvc.Name, pvc.Namespace, err)
|
||||
}
|
||||
|
||||
patchBytes := []byte(`{"spec":{"persistentVolumeReclaimPolicy": "Retain", "claimRef": null}}`)
|
||||
// patch PV to Retain it after deleting the PVC.
|
||||
patchBytes := []byte(`{"spec":{"persistentVolumeReclaimPolicy": "Retain"}}`)
|
||||
_, err = c.CoreV1().PersistentVolumes().Patch(
|
||||
context.TODO(),
|
||||
pvcObj.Spec.VolumeName,
|
||||
@ -533,7 +534,7 @@ var _ = Describe("RBD", func() {
|
||||
patchBytes,
|
||||
metav1.PatchOptions{})
|
||||
if err != nil {
|
||||
e2elog.Logf("error Patching PV %q for persistentVolumeReclaimPolicy and claimRef: %v",
|
||||
e2elog.Logf("error Patching PV %q for persistentVolumeReclaimPolicy: %v",
|
||||
pvcObj.Spec.VolumeName, err)
|
||||
}
|
||||
|
||||
@ -545,6 +546,19 @@ var _ = Describe("RBD", func() {
|
||||
e2elog.Logf("failed to delete pvc: %w", err)
|
||||
}
|
||||
|
||||
// Remove the claimRef to bind this PV to a new PVC.
|
||||
patchBytes = []byte(`{"spec":{"claimRef": null}}`)
|
||||
_, err = c.CoreV1().PersistentVolumes().Patch(
|
||||
context.TODO(),
|
||||
pvcObj.Spec.VolumeName,
|
||||
types.StrategicMergePatchType,
|
||||
patchBytes,
|
||||
metav1.PatchOptions{})
|
||||
if err != nil {
|
||||
e2elog.Logf("error Patching PV %q for claimRef: %v",
|
||||
pvcObj.Spec.VolumeName, err)
|
||||
}
|
||||
|
||||
// validate created backend rbd images
|
||||
validateRBDImageCount(f, 1, defaultRBDPool)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user