From b24805f47a40be165223839266e7b669ace9830c 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 | 39 ++++++++++++++------------------ 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/pkg/controller/plan/migration.go b/pkg/controller/plan/migration.go index 963a113d8..f3f060b1e 100644 --- a/pkg/controller/plan/migration.go +++ b/pkg/controller/plan/migration.go @@ -1389,32 +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 } - importer, found, kErr = r.kubevirt.GetImporterPod(importerPVC) + importer, found, kErr = r.kubevirt.GetImporterPod(*pvc) } if kErr != nil {