diff --git a/images/virtualization-artifact/pkg/controller/cvi/internal/source/http.go b/images/virtualization-artifact/pkg/controller/cvi/internal/source/http.go index ab46e4420..9364843d2 100644 --- a/images/virtualization-artifact/pkg/controller/cvi/internal/source/http.go +++ b/images/virtualization-artifact/pkg/controller/cvi/internal/source/http.go @@ -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 = "" diff --git a/images/virtualization-artifact/pkg/controller/cvi/internal/source/object_ref.go b/images/virtualization-artifact/pkg/controller/cvi/internal/source/object_ref.go index bcf74fa33..b9f0bdbb0 100644 --- a/images/virtualization-artifact/pkg/controller/cvi/internal/source/object_ref.go +++ b/images/virtualization-artifact/pkg/controller/cvi/internal/source/object_ref.go @@ -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 = "" diff --git a/images/virtualization-artifact/pkg/controller/cvi/internal/source/registry.go b/images/virtualization-artifact/pkg/controller/cvi/internal/source/registry.go index b731622f0..00341dc05 100644 --- a/images/virtualization-artifact/pkg/controller/cvi/internal/source/registry.go +++ b/images/virtualization-artifact/pkg/controller/cvi/internal/source/registry.go @@ -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 = "" diff --git a/images/virtualization-artifact/pkg/controller/cvi/internal/source/upload.go b/images/virtualization-artifact/pkg/controller/cvi/internal/source/upload.go index 298ae91b9..55b393e4b 100644 --- a/images/virtualization-artifact/pkg/controller/cvi/internal/source/upload.go +++ b/images/virtualization-artifact/pkg/controller/cvi/internal/source/upload.go @@ -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 = "" diff --git a/images/virtualization-artifact/pkg/controller/vi/internal/source/http.go b/images/virtualization-artifact/pkg/controller/vi/internal/source/http.go index 4d3582c84..a9e74f065 100644 --- a/images/virtualization-artifact/pkg/controller/vi/internal/source/http.go +++ b/images/virtualization-artifact/pkg/controller/vi/internal/source/http.go @@ -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 = "" diff --git a/images/virtualization-artifact/pkg/controller/vi/internal/source/object_ref.go b/images/virtualization-artifact/pkg/controller/vi/internal/source/object_ref.go index 91323082c..8c7c84d8a 100644 --- a/images/virtualization-artifact/pkg/controller/vi/internal/source/object_ref.go +++ b/images/virtualization-artifact/pkg/controller/vi/internal/source/object_ref.go @@ -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 = "" diff --git a/images/virtualization-artifact/pkg/controller/vi/internal/source/registry.go b/images/virtualization-artifact/pkg/controller/vi/internal/source/registry.go index 48ed9b199..98f11b2d4 100644 --- a/images/virtualization-artifact/pkg/controller/vi/internal/source/registry.go +++ b/images/virtualization-artifact/pkg/controller/vi/internal/source/registry.go @@ -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 = "" diff --git a/images/virtualization-artifact/pkg/controller/vi/internal/source/upload.go b/images/virtualization-artifact/pkg/controller/vi/internal/source/upload.go index 7aef1d795..92ef0acc3 100644 --- a/images/virtualization-artifact/pkg/controller/vi/internal/source/upload.go +++ b/images/virtualization-artifact/pkg/controller/vi/internal/source/upload.go @@ -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 = ""