From 1bb78fdf43c17bd33c13028995c83d21bfe053d9 Mon Sep 17 00:00:00 2001 From: Rakshith R Date: Fri, 29 Mar 2024 15:06:01 +0530 Subject: [PATCH] e2e: validate PVC-PVC clone creation with deleted parent snap This commit modifies a test case to check creation of PVC-PVC clone of a restored PVC when parent snapshot is deleted. Signed-off-by: Rakshith R --- e2e/rbd.go | 37 ++++++++++++++++++++++++++++++++++++- internal/rbd/rbd_util.go | 4 ++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/e2e/rbd.go b/e2e/rbd.go index 9c0cf68f5..171015697 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -3553,7 +3553,7 @@ var _ = Describe("RBD", func() { validateRBDImageCount(f, 1, defaultRBDPool) validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType) for i := 0; i < snapChainDepth; i++ { - var pvcClone *v1.PersistentVolumeClaim + var pvcClone, smartClonePVC *v1.PersistentVolumeClaim snap := getSnapshot(snapshotPath) snap.Name = fmt.Sprintf("%s-%d", snap.Name, i) snap.Namespace = f.UniqueName @@ -3610,6 +3610,41 @@ var _ = Describe("RBD", func() { validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType) validateOmapCount(f, 0, rbdType, defaultRBDPool, snapsType) + // create pvc-pvc clone to validate pvc-pvc clone creation + // of child PVC created from a snapshot which no longer exits. + // Snapshot-> restore PVC -> delete Snapshot -> PVC-PVC clone. + smartClonePVC, err = loadPVC(pvcSmartClonePath) + if err != nil { + framework.Failf("failed to load smart clone PVC: %v", err) + } + + smartClonePVC.Name = fmt.Sprintf("%s-%d", smartClonePVC.Name, i) + smartClonePVC.Namespace = f.UniqueName + smartClonePVC.Spec.DataSource.Name = pvcClone.Name + err = createPVCAndvalidatePV(f.ClientSet, smartClonePVC, deployTimeout) + if err != nil { + framework.Failf("failed to create smart clone PVC %q: %v", + smartClonePVC.Name, err) + } + + // validate created backend rbd images = clone + smart clone + temp image + totalImages = 3 + validateRBDImageCount(f, totalImages, defaultRBDPool) + validateOmapCount(f, 2, rbdType, defaultRBDPool, volumesType) + validateOmapCount(f, 0, rbdType, defaultRBDPool, snapsType) + + err = deletePVCAndValidatePV(f.ClientSet, smartClonePVC, deployTimeout) + if err != nil { + framework.Failf("failed to delete smart clone PVC %q: %v", + smartClonePVC.Name, err) + } + + // validate created backend rbd images = clone + totalImages = 1 + validateRBDImageCount(f, totalImages, defaultRBDPool) + validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType) + validateOmapCount(f, 0, rbdType, defaultRBDPool, snapsType) + app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcClone.Name // create application err = createApp(f.ClientSet, app, deployTimeout) diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index c8bacc48a..7b37a70eb 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -116,8 +116,6 @@ type rbdImage struct { ParentName string // Parent Pool is the pool that contains the parent image. ParentPool string - // ParentInTrash indicates the parent image is in trash. - ParentInTrash bool // Cluster name ClusterName string @@ -148,6 +146,8 @@ type rbdImage struct { // Set metadata on volume EnableMetadata bool + // ParentInTrash indicates the parent image is in trash. + ParentInTrash bool } // rbdVolume represents a CSI volume and its RBD image specifics.