Skip to content

Commit

Permalink
fix(vd): add download status
Browse files Browse the repository at this point in the history
Signed-off-by: Isteb4k <[email protected]>
  • Loading branch information
Isteb4k committed Jul 9, 2024
1 parent 04f5479 commit 6d5c0a0
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 248 deletions.
15 changes: 3 additions & 12 deletions api/core/v1alpha2/image_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ const (
)

type ImageStatus struct {
DownloadSpeed ImageStatusSpeed `json:"downloadSpeed"`
Size ImageStatusSize `json:"size"`
Format string `json:"format,omitempty"`
// FIXME: create ClusterImageStatus without Capacity and PersistentVolumeClaim.
Capacity string `json:"capacity,omitempty"`
DownloadSpeed *StatusSpeed `json:"downloadSpeed"`
Size ImageStatusSize `json:"size"`
Format string `json:"format,omitempty"`
CDROM bool `json:"cdrom"`
Target ImageStatusTarget `json:"target"`
Phase ImagePhase `json:"phase,omitempty"`
Expand All @@ -47,13 +45,6 @@ type StatusSpeed struct {
CurrentBytes string `json:"currentBytes,omitempty"`
}

type ImageStatusSpeed struct {
Avg string `json:"avg,omitempty"`
AvgBytes string `json:"avgBytes,omitempty"`
Current string `json:"current,omitempty"`
CurrentBytes string `json:"currentBytes,omitempty"`
}

type ImageStatusSize struct {
Stored string `json:"stored,omitempty"`
StoredBytes string `json:"storedBytes,omitempty"`
Expand Down
9 changes: 1 addition & 8 deletions api/core/v1alpha2/virtual_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type VirtualDiskSpec struct {
}

type VirtualDiskStatus struct {
DownloadSpeed VirtualDiskDownloadSpeed `json:"downloadSpeed"`
DownloadSpeed *StatusSpeed `json:"downloadSpeed,omitempty"`
Capacity string `json:"capacity,omitempty"`
Target DiskTarget `json:"target"`
Progress string `json:"progress,omitempty"`
Expand Down Expand Up @@ -87,13 +87,6 @@ const (
VirtualDiskObjectRefKindClusterVirtualImage VirtualDiskObjectRefKind = "ClusterVirtualImage"
)

type VirtualDiskDownloadSpeed struct {
Avg string `json:"avg,omitempty"`
AvgBytes string `json:"avgBytes,omitempty"`
Current string `json:"current,omitempty"`
CurrentBytes string `json:"currentBytes,omitempty"`
}

type DiskTarget struct {
PersistentVolumeClaim string `json:"persistentVolumeClaimName,omitempty"`
}
Expand Down
48 changes: 12 additions & 36 deletions api/core/v1alpha2/zz_generated.deepcopy.go

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

117 changes: 9 additions & 108 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.

Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func (ds HTTPDataSource) Sync(ctx context.Context, cvi *virtv2.ClusterVirtualIma

cvi.Status.Phase = virtv2.ImageProvisioning
cvi.Status.Progress = ds.statService.GetProgress(cvi.GetUID(), pod, cvi.Status.Progress)
cvi.Status.DownloadSpeed = ds.statService.GetDownloadSpeed(cvi.GetUID(), pod)
cvi.Status.Target.RegistryURL = ds.dvcrSettings.RegistryImageForCVMI(cvi.Name)

envSettings := ds.getEnvSettings(cvi, supgen)
Expand Down Expand Up @@ -131,8 +130,8 @@ func (ds HTTPDataSource) Sync(ctx context.Context, cvi *virtv2.ClusterVirtualIma
cvi.Status.CDROM = ds.statService.GetCDROM(pod)
cvi.Status.Format = ds.statService.GetFormat(pod)
cvi.Status.Progress = ds.statService.GetProgress(cvi.GetUID(), pod, cvi.Status.Progress)
cvi.Status.DownloadSpeed = ds.statService.GetDownloadSpeed(cvi.GetUID(), pod)
cvi.Status.Target.RegistryURL = ds.dvcrSettings.RegistryImageForCVMI(cvi.Name)
cvi.Status.DownloadSpeed = ds.statService.GetDownloadSpeed(cvi.GetUID(), pod)

ds.logger.Info("Ready", "cvi", cvi.Name, "progress", cvi.Status.Progress, "pod.phase", pod.Status.Phase)
default:
Expand Down Expand Up @@ -167,8 +166,8 @@ func (ds HTTPDataSource) Sync(ctx context.Context, cvi *virtv2.ClusterVirtualIma

cvi.Status.Phase = virtv2.ImageProvisioning
cvi.Status.Progress = ds.statService.GetProgress(cvi.GetUID(), pod, cvi.Status.Progress)
cvi.Status.DownloadSpeed = ds.statService.GetDownloadSpeed(cvi.GetUID(), pod)
cvi.Status.Target.RegistryURL = ds.dvcrSettings.RegistryImageForCVMI(cvi.Name)
cvi.Status.DownloadSpeed = ds.statService.GetDownloadSpeed(cvi.GetUID(), pod)

ds.logger.Info("Provisioning...", "cvi", cvi.Name, "progress", cvi.Status.Progress, "pod.phase", pod.Status.Phase)
}
Expand Down
Loading

0 comments on commit 6d5c0a0

Please sign in to comment.