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): add download status #203

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading