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(vi,cvi): fix pod errors handling #162

Merged
merged 1 commit into from
Jun 26, 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
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ func (ds HTTPDataSource) Sync(ctx context.Context, cvi *virtv2.ClusterVirtualIma

ds.logger.Info("Create importer pod...", "cvi", cvi.Name, "progress", cvi.Status.Progress, "pod.phase", "nil")
case common.IsPodComplete(pod):
err = ds.statService.CheckPod(pod)
if err != nil {
cvi.Status.Phase = virtv2.ImageFailed

switch {
case errors.Is(err, service.ErrProvisioningFailed):
condition.Status = metav1.ConditionFalse
condition.Reason = cvicondition.ProvisioningFailed
condition.Message = service.CapitalizeFirstLetter(err.Error() + ".")
return false, nil
default:
return false, err
}
}

condition.Status = metav1.ConditionTrue
condition.Reason = cvicondition.Ready
condition.Message = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ func (ds ObjectRefDataSource) Sync(ctx context.Context, cvi *virtv2.ClusterVirtu

ds.logger.Info("Ready", "cvi", cvi.Name, "progress", cvi.Status.Progress, "pod.phase", "nil")
case common.IsPodComplete(pod):
err = ds.statService.CheckPod(pod)
if err != nil {
cvi.Status.Phase = virtv2.ImageFailed

switch {
case errors.Is(err, service.ErrProvisioningFailed):
condition.Status = metav1.ConditionFalse
condition.Reason = cvicondition.ProvisioningFailed
condition.Message = service.CapitalizeFirstLetter(err.Error() + ".")
return false, nil
default:
return false, err
}
}

condition.Status = metav1.ConditionTrue
condition.Reason = cvicondition.Ready
condition.Message = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ func (ds RegistryDataSource) Sync(ctx context.Context, cvi *virtv2.ClusterVirtua

ds.logger.Info("Create importer pod...", "cvi", cvi.Name, "progress", cvi.Status.Progress, "pod.phase", "nil")
case common.IsPodComplete(pod):
err = ds.statService.CheckPod(pod)
if err != nil {
cvi.Status.Phase = virtv2.ImageFailed

switch {
case errors.Is(err, service.ErrProvisioningFailed):
condition.Status = metav1.ConditionFalse
condition.Reason = cvicondition.ProvisioningFailed
condition.Message = service.CapitalizeFirstLetter(err.Error() + ".")
return false, nil
default:
return false, err
}
}

condition.Status = metav1.ConditionTrue
condition.Reason = cvicondition.Ready
condition.Message = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@ func (ds UploadDataSource) Sync(ctx context.Context, cvi *virtv2.ClusterVirtualI

ds.logger.Info("Create uploader pod...", "cvi", cvi.Name, "progress", cvi.Status.Progress, "pod.phase", nil)
case common.IsPodComplete(pod):
err = ds.statService.CheckPod(pod)
if err != nil {
cvi.Status.Phase = virtv2.ImageFailed

switch {
case errors.Is(err, service.ErrProvisioningFailed):
condition.Status = metav1.ConditionFalse
condition.Reason = cvicondition.ProvisioningFailed
condition.Message = service.CapitalizeFirstLetter(err.Error() + ".")
return false, nil
default:
return false, err
}
}

condition.Status = metav1.ConditionTrue
condition.Reason = cvicondition.Ready
condition.Message = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ func (ds HTTPDataSource) Sync(ctx context.Context, vi *virtv2.VirtualImage) (boo

ds.logger.Info("Create importer pod...", "vi", vi.Name, "progress", vi.Status.Progress, "pod.phase", "nil")
case cc.IsPodComplete(pod):
err = ds.statService.CheckPod(pod)
if err != nil {
vi.Status.Phase = virtv2.ImageFailed

switch {
case errors.Is(err, service.ErrProvisioningFailed):
condition.Status = metav1.ConditionFalse
condition.Reason = vicondition.ProvisioningFailed
condition.Message = service.CapitalizeFirstLetter(err.Error() + ".")
return false, nil
default:
return false, err
}
}

condition.Status = metav1.ConditionTrue
condition.Reason = vicondition.Ready
condition.Message = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ func (ds ObjectRefDataSource) Sync(ctx context.Context, vi *virtv2.VirtualImage)

ds.logger.Info("Ready", "vi", vi.Name, "progress", vi.Status.Progress, "pod.phase", "nil")
case cc.IsPodComplete(pod):
err = ds.statService.CheckPod(pod)
if err != nil {
vi.Status.Phase = virtv2.ImageFailed

switch {
case errors.Is(err, service.ErrProvisioningFailed):
condition.Status = metav1.ConditionFalse
condition.Reason = vicondition.ProvisioningFailed
condition.Message = service.CapitalizeFirstLetter(err.Error() + ".")
return false, nil
default:
return false, err
}
}

condition.Status = metav1.ConditionTrue
condition.Reason = vicondition.Ready
condition.Message = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ func (ds RegistryDataSource) Sync(ctx context.Context, vi *virtv2.VirtualImage)

ds.logger.Info("Create importer pod...", "vi", vi.Name, "progress", vi.Status.Progress, "pod.phase", "nil")
case common.IsPodComplete(pod):
err = ds.statService.CheckPod(pod)
if err != nil {
vi.Status.Phase = virtv2.ImageFailed

switch {
case errors.Is(err, service.ErrProvisioningFailed):
condition.Status = metav1.ConditionFalse
condition.Reason = vicondition.ProvisioningFailed
condition.Message = service.CapitalizeFirstLetter(err.Error() + ".")
return false, nil
default:
return false, err
}
}

condition.Status = metav1.ConditionTrue
condition.Reason = vicondition.Ready
condition.Message = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ func (ds UploadDataSource) Sync(ctx context.Context, vi *virtv2.VirtualImage) (b

ds.logger.Info("Create uploader pod...", "vi", vi.Name, "progress", vi.Status.Progress, "pod.phase", nil)
case common.IsPodComplete(pod):
err = ds.statService.CheckPod(pod)
if err != nil {
vi.Status.Phase = virtv2.ImageFailed

switch {
case errors.Is(err, service.ErrProvisioningFailed):
condition.Status = metav1.ConditionFalse
condition.Reason = vicondition.ProvisioningFailed
condition.Message = service.CapitalizeFirstLetter(err.Error() + ".")
return false, nil
default:
return false, err
}
}

condition.Status = metav1.ConditionTrue
condition.Reason = vicondition.Ready
condition.Message = ""
Expand Down
Loading