Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-v1.61] CNV-52722: Pass through extra VDDK configuration options to importer pod. #3607

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Copy extra VDDK args annotation for populators.
Also add a related unit test.

Signed-off-by: Matthew Arnold <marnold@redhat.com>
mrnold authored and kubevirt-bot committed Jan 21, 2025
commit 822bd133fecfa0fd184c7b132cba1d66779bb915
56 changes: 56 additions & 0 deletions pkg/controller/populators/import-populator_test.go
Original file line number Diff line number Diff line change
@@ -501,6 +501,62 @@ var _ = Describe("Import populator tests", func() {
Expect(pvcPrime.GetAnnotations()[AnnCurrentCheckpoint]).To(Equal("current"))
Expect(pvcPrime.GetAnnotations()[AnnFinalCheckpoint]).To(Equal("true"))
})

It("Should create PVC prime with proper VDDK import annotations", func() {
targetPvc := CreatePvcInStorageClass(targetPvcName, metav1.NamespaceDefault, &sc.Name, map[string]string{}, nil, corev1.ClaimPending)
targetPvc.Spec.DataSourceRef = dataSourceRef
targetPvc.Annotations[AnnVddkExtraArgs] = "vddk-extras"

volumeImportSource := getVolumeImportSource(true, metav1.NamespaceDefault)
volumeImportSource.Spec.Source = &cdiv1.ImportSourceType{
VDDK: &cdiv1.DataVolumeSourceVDDK{
BackingFile: "testBackingFile",
SecretRef: "testSecret",
Thumbprint: "testThumbprint",
URL: "testUrl",
UUID: "testUUID",
},
}

By("Reconcile")
reconciler = createImportPopulatorReconciler(targetPvc, volumeImportSource, sc)
result, err := reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: types.NamespacedName{Name: targetPvcName, Namespace: metav1.NamespaceDefault}})
Expect(err).To(Not(HaveOccurred()))
Expect(result).To(Not(BeNil()))

By("Checking events recorded")
close(reconciler.recorder.(*record.FakeRecorder).Events)
found := false
for event := range reconciler.recorder.(*record.FakeRecorder).Events {
if strings.Contains(event, createdPVCPrimeSuccessfully) {
found = true
}
}
reconciler.recorder = nil
Expect(found).To(BeTrue())

By("Checking PVC' annotations")
pvcPrime, err := reconciler.getPVCPrime(targetPvc)
Expect(err).ToNot(HaveOccurred())
Expect(pvcPrime).ToNot(BeNil())
// make sure we didnt inflate size
Expect(pvcPrime.Spec.Resources.Requests[corev1.ResourceStorage]).To(Equal(resource.MustParse("1G")))
Expect(pvcPrime.GetAnnotations()).ToNot(BeNil())
Expect(pvcPrime.GetAnnotations()[AnnImmediateBinding]).To(Equal(""))
Expect(pvcPrime.GetAnnotations()[AnnUploadRequest]).To(Equal(""))
Expect(pvcPrime.GetAnnotations()[AnnPopulatorKind]).To(Equal(cdiv1.VolumeImportSourceRef))
Expect(pvcPrime.GetAnnotations()[AnnPreallocationRequested]).To(Equal("true"))
Expect(pvcPrime.GetAnnotations()[AnnBackingFile]).To(Equal("testBackingFile"))
Expect(pvcPrime.GetAnnotations()[AnnSecret]).To(Equal("testSecret"))
Expect(pvcPrime.GetAnnotations()[AnnThumbprint]).To(Equal("testThumbprint"))
Expect(pvcPrime.GetAnnotations()[AnnEndpoint]).To(Equal("testUrl"))
Expect(pvcPrime.GetAnnotations()[AnnUUID]).To(Equal("testUUID"))
Expect(pvcPrime.GetAnnotations()[AnnSource]).To(Equal(SourceVDDK))
Expect(pvcPrime.GetLabels()[LabelExcludeFromVeleroBackup]).To(Equal("true"))

Expect(pvcPrime.GetAnnotations()[AnnVddkExtraArgs]).To(Equal("vddk-extras"))
})

})

var _ = Describe("Import populator progress report", func() {
3 changes: 3 additions & 0 deletions pkg/controller/populators/populator-base.go
Original file line number Diff line number Diff line change
@@ -181,6 +181,9 @@ func (r *ReconcilerBase) createPVCPrime(pvc *corev1.PersistentVolumeClaim, sourc
if _, ok := pvc.Annotations[cc.AnnPodRetainAfterCompletion]; ok {
annotations[cc.AnnPodRetainAfterCompletion] = pvc.Annotations[cc.AnnPodRetainAfterCompletion]
}
if vddkExtraArgs, ok := pvc.Annotations[cc.AnnVddkExtraArgs]; ok && vddkExtraArgs != "" {
annotations[cc.AnnVddkExtraArgs] = vddkExtraArgs
}

// Assemble PVC' spec
pvcPrime := &corev1.PersistentVolumeClaim{