diff --git a/pkg/controller/plan/kubevirt.go b/pkg/controller/plan/kubevirt.go index 4dfc6704a..0283afe1f 100644 --- a/pkg/controller/plan/kubevirt.go +++ b/pkg/controller/plan/kubevirt.go @@ -937,25 +937,22 @@ func (r *KubeVirt) DeletePVCs(vm *plan.VMStatus) (err error) { for _, pvc := range pvcs { primePVC := core.PersistentVolumeClaim{} err = r.Destination.Client.Get(context.TODO(), client.ObjectKey{Namespace: r.Plan.Spec.TargetNamespace, Name: fmt.Sprintf("prime-%s", string(pvc.UID))}, &primePVC) - if err != nil { - if k8serr.IsNotFound(err) { - err = nil - } - continue + if err != nil && k8serr.IsNotFound(err) { + err = nil + } else if err != nil { + return } // Best effort deletion err = r.DeleteObject(&primePVC, vm, "Deleted prime PVC.", "pvc") if err != nil && k8serr.IsNotFound(err) { err = nil - } - if err != nil { + } else if err != nil { return } err = r.DeleteObject(&pvc, vm, "Deleted PVC.", "pvc") if err != nil && k8serr.IsNotFound(err) { err = nil - } - if err != nil { + } else if err != nil { return } pvcCopy := pvc.DeepCopy() diff --git a/pkg/controller/plan/migration.go b/pkg/controller/plan/migration.go index f674433f0..33bae589b 100644 --- a/pkg/controller/plan/migration.go +++ b/pkg/controller/plan/migration.go @@ -424,7 +424,9 @@ func (r *Migration) Cancel() (err error) { } func (r *Migration) cleanUpPopulatorPVCs(vm *plan.VMStatus) (err error) { - err = r.kubevirt.DeletePVCs(vm) + if r.builder.SupportsVolumePopulators() { + err = r.kubevirt.DeletePVCs(vm) + } return } @@ -435,11 +437,9 @@ func (r *Migration) cleanup(vm *plan.VMStatus) (err error) { if err != nil { return } - if r.builder.SupportsVolumePopulators() { - err = r.cleanUpPopulatorPVCs(vm) - if err != nil { - return - } + err = r.cleanUpPopulatorPVCs(vm) + if err != nil { + return } } err = r.deleteImporterPods(vm)