Merge pull request #127805 from venkatsc/fix_e2e_127804

Fix pre-provisioned snapshots e2e test
This commit is contained in:
Kubernetes Prow Robot 2024-10-02 23:46:26 +01:00 committed by GitHub
commit 380c00d58f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -111,6 +111,7 @@ func CreateSnapshotResource(ctx context.Context, sDriver SnapshottableTestDriver
framework.Logf("Recording snapshot content annotations: %v", snapshotContentAnnotations) framework.Logf("Recording snapshot content annotations: %v", snapshotContentAnnotations)
csiDriverName := r.Vsclass.Object["driver"].(string) csiDriverName := r.Vsclass.Object["driver"].(string)
framework.Logf("Recording snapshot driver: %s", csiDriverName) framework.Logf("Recording snapshot driver: %s", csiDriverName)
snapshotClassName := r.Vsclass.GetName()
// If the deletion policy is retain on vscontent: // If the deletion policy is retain on vscontent:
// when vs is deleted vscontent will not be deleted // when vs is deleted vscontent will not be deleted
@ -143,7 +144,7 @@ func CreateSnapshotResource(ctx context.Context, sDriver SnapshottableTestDriver
snapName := getPreProvisionedSnapshotName(uuid) snapName := getPreProvisionedSnapshotName(uuid)
snapcontentName := getPreProvisionedSnapshotContentName(uuid) snapcontentName := getPreProvisionedSnapshotContentName(uuid)
r.Vscontent = getPreProvisionedSnapshotContent(snapcontentName, snapshotContentAnnotations, snapName, pvcNamespace, snapshotHandle, pattern.SnapshotDeletionPolicy.String(), csiDriverName) r.Vscontent = getPreProvisionedSnapshotContent(snapcontentName, snapshotClassName, snapshotContentAnnotations, snapName, pvcNamespace, snapshotHandle, pattern.SnapshotDeletionPolicy.String(), csiDriverName)
r.Vscontent, err = dc.Resource(utils.SnapshotContentGVR).Create(ctx, r.Vscontent, metav1.CreateOptions{}) r.Vscontent, err = dc.Resource(utils.SnapshotContentGVR).Create(ctx, r.Vscontent, metav1.CreateOptions{})
framework.ExpectNoError(err) framework.ExpectNoError(err)
@ -302,7 +303,7 @@ func getPreProvisionedSnapshot(snapName, ns, snapshotContentName string) *unstru
return snapshot return snapshot
} }
func getPreProvisionedSnapshotContent(snapcontentName string, snapshotContentAnnotations map[string]string, snapshotName, snapshotNamespace, snapshotHandle, deletionPolicy, csiDriverName string) *unstructured.Unstructured { func getPreProvisionedSnapshotContent(snapcontentName, snapshotClassName string, snapshotContentAnnotations map[string]string, snapshotName, snapshotNamespace, snapshotHandle, deletionPolicy, csiDriverName string) *unstructured.Unstructured {
snapshotContent := &unstructured.Unstructured{ snapshotContent := &unstructured.Unstructured{
Object: map[string]interface{}{ Object: map[string]interface{}{
"kind": "VolumeSnapshotContent", "kind": "VolumeSnapshotContent",
@ -315,6 +316,7 @@ func getPreProvisionedSnapshotContent(snapcontentName string, snapshotContentAnn
"source": map[string]interface{}{ "source": map[string]interface{}{
"snapshotHandle": snapshotHandle, "snapshotHandle": snapshotHandle,
}, },
"volumeSnapshotClassName": snapshotClassName,
"volumeSnapshotRef": map[string]interface{}{ "volumeSnapshotRef": map[string]interface{}{
"name": snapshotName, "name": snapshotName,
"namespace": snapshotNamespace, "namespace": snapshotNamespace,