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

fix(vd): fix create vd from vi on pvc #552

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
LopatinDmitr marked this conversation as resolved.
Show resolved Hide resolved
readyCB := conditions.NewConditionBuilder(vicondition.ReadyType).
Generation(vi.Generation).
Status(metav1.ConditionFalse).
Expand All @@ -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 &&
LopatinDmitr marked this conversation as resolved.
Show resolved Hide resolved
readyCondition.Status != metav1.ConditionTrue &&
storageClassReadyCondition.Status != metav1.ConditionTrue &&
vi.Status.StorageClassName != "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ var _ = Describe("LifeCycleHandler Run", func() {
Status: metav1.ConditionFalse,
},
StorageClassInStatus: "sc",
StorageType: virtv2.StorageKubernetes,
StorageType: virtv2.StoragePersistentVolumeClaim,
ExpectCleanup: true,
},
),
Expand Down Expand Up @@ -196,7 +196,7 @@ var _ = Describe("LifeCycleHandler Run", func() {
Status: metav1.ConditionFalse,
},
StorageClassInStatus: "",
StorageType: virtv2.StorageKubernetes,
StorageType: virtv2.StoragePersistentVolumeClaim,
ExpectCleanup: false,
},
),
Expand All @@ -210,7 +210,7 @@ var _ = Describe("LifeCycleHandler Run", func() {
Status: metav1.ConditionFalse,
},
StorageClassInStatus: "sc",
StorageType: virtv2.StorageKubernetes,
StorageType: virtv2.StoragePersistentVolumeClaim,
ExpectCleanup: false,
},
),
Expand All @@ -224,7 +224,7 @@ var _ = Describe("LifeCycleHandler Run", func() {
Status: metav1.ConditionTrue,
},
StorageClassInStatus: "sc",
StorageType: virtv2.StorageKubernetes,
StorageType: virtv2.StoragePersistentVolumeClaim,
ExpectCleanup: false,
},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand Down
Loading