Fix pre-provisioned snapshots e2e test

VolumeSnapshotContents object created for the pre-provisioned
snapshots does not include VolumeSnapshotClass. Therefore
secrets required by backing CSI driver cannot be provided
via external snapshot controller. The missing secrets causes
failure in the backing CSI driver.
This commit is contained in:
Venkata Subbarao Chunduri 2024-10-02 12:49:20 +02:00
parent a95db41434
commit 0cd878dba0

View File

@ -111,6 +111,7 @@ func CreateSnapshotResource(ctx context.Context, sDriver SnapshottableTestDriver
framework.Logf("Recording snapshot content annotations: %v", snapshotContentAnnotations)
csiDriverName := r.Vsclass.Object["driver"].(string)
framework.Logf("Recording snapshot driver: %s", csiDriverName)
snapshotClassName := r.Vsclass.GetName()
// If the deletion policy is retain on vscontent:
// when vs is deleted vscontent will not be deleted
@ -143,7 +144,7 @@ func CreateSnapshotResource(ctx context.Context, sDriver SnapshottableTestDriver
snapName := getPreProvisionedSnapshotName(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{})
framework.ExpectNoError(err)
@ -302,7 +303,7 @@ func getPreProvisionedSnapshot(snapName, ns, snapshotContentName string) *unstru
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{
Object: map[string]interface{}{
"kind": "VolumeSnapshotContent",
@ -315,6 +316,7 @@ func getPreProvisionedSnapshotContent(snapcontentName string, snapshotContentAnn
"source": map[string]interface{}{
"snapshotHandle": snapshotHandle,
},
"volumeSnapshotClassName": snapshotClassName,
"volumeSnapshotRef": map[string]interface{}{
"name": snapshotName,
"namespace": snapshotNamespace,