Skip to content

Commit

Permalink
fix(vd,vi,cvi): fix capacity and cdrom
Browse files Browse the repository at this point in the history
Signed-off-by: Isteb4k <[email protected]>
  • Loading branch information
Isteb4k committed Jun 27, 2024
1 parent aae4b4e commit 73f929d
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 47 deletions.
2 changes: 1 addition & 1 deletion api/core/v1alpha2/image_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type ImageStatus struct {
Format string `json:"format,omitempty"`
// FIXME: create ClusterImageStatus without Capacity and PersistentVolumeClaim.
Capacity string `json:"capacity,omitempty"`
CDROM bool `json:"cdrom,omitempty"`
CDROM bool `json:"cdrom"`
Target ImageStatusTarget `json:"target"`
Phase ImagePhase `json:"phase,omitempty"`
Progress string `json:"progress,omitempty"`
Expand Down
9 changes: 8 additions & 1 deletion api/core/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 26 additions & 40 deletions api/pkg/apiserver/api/generated/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions images/virtualization-artifact/pkg/controller/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,11 @@ func IsDataVolumeComplete(dv *cdiv1.DataVolume) bool {
return dv != nil && dv.Status.Phase == cdiv1.Succeeded
}

// IsPVCBound returns true if a PersistentVolumeClaim is in 'Bound' phase, false if not.
func IsPVCBound(pvc *corev1.PersistentVolumeClaim) bool {
return pvc != nil && pvc.Status.Phase == corev1.ClaimBound
}

func IsTerminating(obj client.Object) bool {
return !reflect.ValueOf(obj).IsNil() && obj.GetDeletionTimestamp() != nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ func (s DiskService) Resize(ctx context.Context, pvc *corev1.PersistentVolumeCla
}
}

func (s DiskService) IsImportDone(dv *cdiv1.DataVolume, pvc *corev1.PersistentVolumeClaim) bool {
return common.IsDataVolumeComplete(dv) && common.IsPVCBound(pvc)
}

func (s DiskService) GetProgress(dv *cdiv1.DataVolume, prevProgress string, opts ...GetProgressOption) string {
if dv == nil {
return prevProgress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (ds BlankDataSource) Sync(ctx context.Context, vd *virtv2.VirtualDisk) (boo
ds.logger.Info("Create data volume...", "vd", vd.Name, "progress", vd.Status.Progress, "dv.phase", "nil")

return true, nil
case common.IsDataVolumeComplete(dv):
case ds.diskService.IsImportDone(dv, pvc):
vd.Status.Phase = virtv2.DiskReady
condition.Status = metav1.ConditionTrue
condition.Reason = vdcondition.Ready
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (ds HTTPDataSource) Sync(ctx context.Context, vd *virtv2.VirtualDisk) (bool
ds.logger.Info("Create data volume...", "vd", vd.Name, "progress", vd.Status.Progress, "dv.phase", "nil")

return true, nil
case common.IsDataVolumeComplete(dv):
case ds.diskService.IsImportDone(dv, pvc):
vd.Status.Phase = virtv2.DiskReady
condition.Status = metav1.ConditionTrue
condition.Reason = vdcondition.Ready
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (ds ObjectRefDataSource) Sync(ctx context.Context, vd *virtv2.VirtualDisk)
ds.logger.Info("Create data volume...", "vd", vd.Name, "progress", vd.Status.Progress, "dv.phase", "nil")

return true, nil
case common.IsDataVolumeComplete(dv):
case ds.diskService.IsImportDone(dv, pvc):
vd.Status.Phase = virtv2.DiskReady
condition.Status = metav1.ConditionTrue
condition.Reason = vdcondition.Ready
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (ds RegistryDataSource) Sync(ctx context.Context, vd *virtv2.VirtualDisk) (
ds.logger.Info("Create data volume...", "vd", vd.Name, "progress", vd.Status.Progress, "dv.phase", "nil")

return true, nil
case common.IsDataVolumeComplete(dv):
case ds.diskService.IsImportDone(dv, pvc):
vd.Status.Phase = virtv2.DiskReady
condition.Status = metav1.ConditionTrue
condition.Reason = vdcondition.Ready
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func (ds UploadDataSource) Sync(ctx context.Context, vd *virtv2.VirtualDisk) (bo
ds.logger.Info("Create data volume...", "vd", vd.Name, "progress", vd.Status.Progress, "dv.phase", "nil")

return true, nil
case common.IsDataVolumeComplete(dv):
case ds.diskService.IsImportDone(dv, pvc):
vd.Status.Phase = virtv2.DiskReady
condition.Status = metav1.ConditionTrue
condition.Reason = vdcondition.Ready
Expand Down

0 comments on commit 73f929d

Please sign in to comment.