From 43417c8f906c6b97b643ea86c8867066716cf854 Mon Sep 17 00:00:00 2001 From: Benny Zlotnik Date: Thu, 10 Aug 2023 13:45:18 +0300 Subject: [PATCH] Check claimName on DV status It seems like dv.PVC is always nil because we don't create a DV from a PVC, this leads to failing to find the DV whenever the importer pod fails and it will restart forever instead of 3 times Signed-off-by: Benny Zlotnik --- pkg/controller/plan/migration.go | 37 +++++++++++++++----------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/pkg/controller/plan/migration.go b/pkg/controller/plan/migration.go index 963a113d8..9f896141a 100644 --- a/pkg/controller/plan/migration.go +++ b/pkg/controller/plan/migration.go @@ -1389,30 +1389,27 @@ func (r *Migration) updateCopyProgress(vm *plan.VMStatus, step *plan.Step) (err var importer *core.Pod var found bool var kErr error - if dv.PVC == nil && !r.Plan.IsSourceProviderOCP() { + + if dv.Status.ClaimName == "" { found = false } else { var importerPVC core.PersistentVolumeClaim - if r.Plan.IsSourceProviderOCP() { - pvc := &core.PersistentVolumeClaim{} - err = r.Destination.Client.Get(context.TODO(), types.NamespacedName{ - Namespace: r.Plan.Spec.TargetNamespace, - Name: dv.Status.ClaimName, - }, pvc) - if err != nil { - log.Error( - err, - "Could not get PVC for DataVolume.", - "vm", - vm.String(), - "dv", - path.Join(dv.Namespace, dv.Name)) - continue - } - importerPVC = *pvc - } else { - importerPVC = *dv.PVC + pvc := &core.PersistentVolumeClaim{} + err = r.Destination.Client.Get(context.TODO(), types.NamespacedName{ + Namespace: r.Plan.Spec.TargetNamespace, + Name: dv.Status.ClaimName, + }, pvc) + if err != nil { + log.Error( + err, + "Could not get PVC for DataVolume.", + "vm", + vm.String(), + "dv", + path.Join(dv.Namespace, dv.Name)) + continue } + importerPVC = *pvc importer, found, kErr = r.kubevirt.GetImporterPod(importerPVC) }