kubevirt/0014-Export-create-populator-compatible-datavolumes-from-.patch
Vasily Ulyanov 17bc60771d Accepting request 1104343 from home:vulyanov:branches:Virtualization
- Create export VM datavolumes compatible with populators
  0014-Export-create-populator-compatible-datavolumes-from-.patch

OBS-URL: https://build.opensuse.org/request/show/1104343
OBS-URL: https://build.opensuse.org/package/show/Virtualization/kubevirt?expand=0&rev=131
2023-08-17 09:15:47 +00:00

57 lines
2.1 KiB
Diff

From 28f503c1417df30de3c7db8c14ced7c8985c9612 Mon Sep 17 00:00:00 2001
From: Alexander Wels <awels@redhat.com>
Date: Thu, 13 Jul 2023 14:33:29 -0500
Subject: [PATCH] Export create populator compatible datavolumes from VM
The generated DataVolumes were not compatible with populator
populated sources. In particular the populators would have
a datasource or datasourceRef set.
This commit clears the values so that the target CDI can
properly generate PVCs from the Datavolume
Signed-off-by: Alexander Wels <awels@redhat.com>
---
pkg/storage/export/export/export.go | 3 +++
pkg/storage/export/export/export_test.go | 4 ++++
2 files changed, 7 insertions(+)
diff --git a/pkg/storage/export/export/export.go b/pkg/storage/export/export/export.go
index c1ba57174..51eb69df6 100644
--- a/pkg/storage/export/export/export.go
+++ b/pkg/storage/export/export/export.go
@@ -1429,6 +1429,9 @@ func (ctrl *VMExportController) createExportHttpDvFromPVC(namespace, name string
if pvc != nil {
pvc.Spec.VolumeName = ""
pvc.Spec.StorageClassName = nil
+ // Don't copy datasources, will be populated by CDI with the datavolume
+ pvc.Spec.DataSource = nil
+ pvc.Spec.DataSourceRef = nil
return &cdiv1.DataVolume{
ObjectMeta: metav1.ObjectMeta{
Name: name,
diff --git a/pkg/storage/export/export/export_test.go b/pkg/storage/export/export/export_test.go
index 15941984d..a341bdca6 100644
--- a/pkg/storage/export/export/export_test.go
+++ b/pkg/storage/export/export/export_test.go
@@ -1310,12 +1310,16 @@ var _ = Describe("Export controller", func() {
It("Should generate DataVolumes from VM", func() {
pvc := createPVC("pvc", string(cdiv1.DataVolumeKubeVirt))
+ pvc.Spec.DataSource = &k8sv1.TypedLocalObjectReference{}
+ pvc.Spec.DataSourceRef = &k8sv1.TypedObjectReference{}
pvcInformer.GetStore().Add(pvc)
vm := createVMWithDVTemplateAndPVC()
dvs := controller.generateDataVolumesFromVm(vm)
Expect(dvs).To(HaveLen(1))
Expect(dvs[0]).ToNot(BeNil())
Expect(dvs[0].Name).To((Equal("pvc")))
+ Expect(dvs[0].Spec.PVC.DataSource).To(BeNil())
+ Expect(dvs[0].Spec.PVC.DataSourceRef).To(BeNil())
})
})
--
2.41.0