diff --git a/images/virtualization-artifact/pkg/controller/vd/internal/source/object_ref.go b/images/virtualization-artifact/pkg/controller/vd/internal/source/object_ref.go index 928bbbf4a..5999a7635 100644 --- a/images/virtualization-artifact/pkg/controller/vd/internal/source/object_ref.go +++ b/images/virtualization-artifact/pkg/controller/vd/internal/source/object_ref.go @@ -75,7 +75,8 @@ func (ds ObjectRefDataSource) Sync(ctx context.Context, vd *virtv2.VirtualDisk) } switch vi.Spec.Storage { - case virtv2.StorageKubernetes: + case virtv2.StorageKubernetes, + virtv2.StoragePersistentVolumeClaim: return ds.viPVCSyncer.Sync(ctx, vd) case virtv2.StorageContainerRegistry: return ds.viDVCRSyncer.Sync(ctx, vd) @@ -117,7 +118,8 @@ func (ds ObjectRefDataSource) Validate(ctx context.Context, vd *virtv2.VirtualDi } switch vi.Spec.Storage { - case virtv2.StorageKubernetes: + case virtv2.StorageKubernetes, + virtv2.StoragePersistentVolumeClaim: return ds.viPVCSyncer.Validate(ctx, vd) case virtv2.StorageContainerRegistry: return ds.viDVCRSyncer.Validate(ctx, vd) diff --git a/images/virtualization-artifact/pkg/controller/vi/internal/life_cycle.go b/images/virtualization-artifact/pkg/controller/vi/internal/life_cycle.go index a20fba260..3fcc1100d 100644 --- a/images/virtualization-artifact/pkg/controller/vi/internal/life_cycle.go +++ b/images/virtualization-artifact/pkg/controller/vi/internal/life_cycle.go @@ -93,7 +93,7 @@ func (h LifeCycleHandler) Handle(ctx context.Context, vi *virtv2.VirtualImage) ( return reconcile.Result{Requeue: true}, fmt.Errorf("condition %s not found", vicondition.StorageClassReadyType) } - if readyCondition.Status != metav1.ConditionTrue && vi.Spec.Storage == virtv2.StorageKubernetes && storageClassReadyCondition.Status != metav1.ConditionTrue { + if readyCondition.Status != metav1.ConditionTrue && (vi.Spec.Storage == virtv2.StorageKubernetes || vi.Spec.Storage == virtv2.StoragePersistentVolumeClaim) && storageClassReadyCondition.Status != metav1.ConditionTrue { readyCB := conditions.NewConditionBuilder(vicondition.ReadyType). Generation(vi.Generation). Status(metav1.ConditionFalse). @@ -102,7 +102,7 @@ func (h LifeCycleHandler) Handle(ctx context.Context, vi *virtv2.VirtualImage) ( conditions.SetCondition(readyCB, &vi.Status.Conditions) } - if vi.Spec.Storage == virtv2.StorageKubernetes && + if (vi.Spec.Storage == virtv2.StorageKubernetes || vi.Spec.Storage == virtv2.StoragePersistentVolumeClaim) && readyCondition.Status != metav1.ConditionTrue && storageClassReadyCondition.Status != metav1.ConditionTrue && vi.Status.StorageClassName != "" { diff --git a/images/virtualization-artifact/pkg/controller/vi/internal/life_cycle_test.go b/images/virtualization-artifact/pkg/controller/vi/internal/life_cycle_test.go index 780a3b7f0..548320453 100644 --- a/images/virtualization-artifact/pkg/controller/vi/internal/life_cycle_test.go +++ b/images/virtualization-artifact/pkg/controller/vi/internal/life_cycle_test.go @@ -168,7 +168,7 @@ var _ = Describe("LifeCycleHandler Run", func() { Status: metav1.ConditionFalse, }, StorageClassInStatus: "sc", - StorageType: virtv2.StorageKubernetes, + StorageType: virtv2.StoragePersistentVolumeClaim, ExpectCleanup: true, }, ), @@ -196,7 +196,7 @@ var _ = Describe("LifeCycleHandler Run", func() { Status: metav1.ConditionFalse, }, StorageClassInStatus: "", - StorageType: virtv2.StorageKubernetes, + StorageType: virtv2.StoragePersistentVolumeClaim, ExpectCleanup: false, }, ), @@ -210,7 +210,7 @@ var _ = Describe("LifeCycleHandler Run", func() { Status: metav1.ConditionFalse, }, StorageClassInStatus: "sc", - StorageType: virtv2.StorageKubernetes, + StorageType: virtv2.StoragePersistentVolumeClaim, ExpectCleanup: false, }, ), @@ -224,7 +224,7 @@ var _ = Describe("LifeCycleHandler Run", func() { Status: metav1.ConditionTrue, }, StorageClassInStatus: "sc", - StorageType: virtv2.StorageKubernetes, + StorageType: virtv2.StoragePersistentVolumeClaim, ExpectCleanup: false, }, ), diff --git a/images/virtualization-artifact/pkg/controller/vi/internal/storageclass_ready_test.go b/images/virtualization-artifact/pkg/controller/vi/internal/storageclass_ready_test.go index 23aac976a..1d727fcef 100644 --- a/images/virtualization-artifact/pkg/controller/vi/internal/storageclass_ready_test.go +++ b/images/virtualization-artifact/pkg/controller/vi/internal/storageclass_ready_test.go @@ -59,7 +59,7 @@ var _ = Describe("StorageClassHandler Run", func() { "StorageClassReady must be false because no storage class can be return", handlerTestArgs{ DiskServiceMock: newDiskServiceMock(nil), - VI: newVI(nil, virtv2.StorageKubernetes), + VI: newVI(nil, virtv2.StoragePersistentVolumeClaim), ExpectedCondition: metav1.Condition{ Status: metav1.ConditionFalse, Reason: vicondition.StorageClassNotFound.String(), @@ -70,7 +70,7 @@ var _ = Describe("StorageClassHandler Run", func() { "StorageClassReady must be true because storage class from spec found", handlerTestArgs{ DiskServiceMock: newDiskServiceMock(ptr.To("sc")), - VI: newVI(ptr.To("sc"), virtv2.StorageKubernetes), + VI: newVI(ptr.To("sc"), virtv2.StoragePersistentVolumeClaim), ExpectedCondition: metav1.Condition{ Status: metav1.ConditionTrue, Reason: vicondition.StorageClassReady.String(), @@ -81,7 +81,7 @@ var _ = Describe("StorageClassHandler Run", func() { "StorageClassReady must be true because default storage class found", handlerTestArgs{ DiskServiceMock: newDiskServiceMock(ptr.To("sc")), - VI: newVI(ptr.To("sc"), virtv2.StorageKubernetes), + VI: newVI(ptr.To("sc"), virtv2.StoragePersistentVolumeClaim), ExpectedCondition: metav1.Condition{ Status: metav1.ConditionTrue, Reason: vicondition.StorageClassReady.String(),