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 committed Aug 10, 2023
1 parent 76efe8a commit 43417c8
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions pkg/controller/plan/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 43417c8

Please sign in to comment.