Skip to content

Commit

Permalink
Check claimName on DV status
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bennyz authored and ahadas committed Aug 15, 2023
1 parent 914c433 commit 20be7ac
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions pkg/controller/plan/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 20be7ac

Please sign in to comment.