diff --git a/e2e/rbd.go b/e2e/rbd.go index 781dc29af..1f026d0a9 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -1102,7 +1102,8 @@ var _ = Describe("RBD", func() { snapshotPath, pvcClonePath, appClonePath, - noKMS, + noKMS, noKMS, + defaultSCName, f) } }) @@ -1169,7 +1170,11 @@ var _ = Describe("RBD", func() { e2elog.Failf("failed to create storageclass with error %v", err) } - validatePVCSnapshot(1, pvcPath, appPath, snapshotPath, pvcClonePath, appClonePath, vaultKMS, f) + validatePVCSnapshot(1, + pvcPath, appPath, snapshotPath, pvcClonePath, appClonePath, + vaultKMS, vaultKMS, + defaultSCName, + f) err = deleteResource(rbdExamplePath + "storageclass.yaml") if err != nil { diff --git a/e2e/utils.go b/e2e/utils.go index b691c1809..5359e9940 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -758,7 +758,8 @@ func validatePVCClone( func validatePVCSnapshot( totalCount int, pvcPath, appPath, snapshotPath, pvcClonePath, appClonePath string, - kms kmsConfig, + kms, restoreKMS kmsConfig, + restoreSCName string, f *framework.Framework) { var wg sync.WaitGroup wgErrs := make([]error, totalCount) @@ -859,6 +860,9 @@ func validatePVCSnapshot( pvcClone.Namespace = f.UniqueName appClone.Namespace = f.UniqueName pvcClone.Spec.DataSource.Name = fmt.Sprintf("%s%d", f.UniqueName, 0) + if restoreSCName != "" { + pvcClone.Spec.StorageClassName = &restoreSCName + } // create multiple PVC from same snapshot wg.Add(totalCount) @@ -872,6 +876,26 @@ func validatePVCSnapshot( LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]), } wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout) + if wgErrs[n] == nil && restoreKMS != noKMS { + if restoreKMS.canGetPassphrase() { + imageData, sErr := getImageInfoFromPVC(p.Namespace, name, f) + if sErr != nil { + wgErrs[n] = fmt.Errorf( + "failed to get image info for %s namespace=%s volumehandle=%s error=%w", + name, + p.Namespace, + imageData.csiVolumeHandle, + sErr) + } else { + // check new passphrase created + _, stdErr := restoreKMS.getPassphrase(f, imageData.csiVolumeHandle) + if stdErr != "" { + wgErrs[n] = fmt.Errorf("failed to read passphrase from vault: %s", stdErr) + } + } + } + wgErrs[n] = isEncryptedPVC(f, &p, &a) + } if wgErrs[n] == nil { filePath := a.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" var checkSumClone string @@ -888,9 +912,6 @@ func validatePVCSnapshot( checkSumClone) } } - if wgErrs[n] == nil && kms != noKMS { - wgErrs[n] = isEncryptedPVC(f, &p, &a) - } wg.Done() }(i, *pvcClone, *appClone) }