From 94a337b495535aed40ef48d8a74f946413fa6dc2 Mon Sep 17 00:00:00 2001 From: Bella Khizgiyaev Date: Wed, 4 Oct 2023 15:12:42 +0300 Subject: [PATCH] Change PVC bining pooling to match v2.5.1 wait version for backport https://github.com/kubev2v/forklift/pull/592 Signed-off-by: Bella Khizgiyaev --- pkg/controller/plan/kubevirt.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/controller/plan/kubevirt.go b/pkg/controller/plan/kubevirt.go index 44d3e0802..79f314040 100644 --- a/pkg/controller/plan/kubevirt.go +++ b/pkg/controller/plan/kubevirt.go @@ -1969,18 +1969,22 @@ func (r *KubeVirt) CreatePvcForNfs(pvcName string) (err error) { Name: pvcName, } - if err = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 45*time.Second, true, func(ctx context.Context) (done bool, err error) { - err = r.Get(context.TODO(), pvcNamespacedName, pvc) + timeout := 45 * time.Second + ctx, cancel := context.WithTimeout(context.TODO(), timeout) + defer cancel() + + // wait until pvc and pv are bound. + err = wait.PollImmediateUntil(5*time.Second, func() (bool, error) { + err := r.Get(context.TODO(), pvcNamespacedName, pvc) if err != nil { r.Log.Error(err, "Failed to get OVA plan PVC") return false, err } return pvc.Status.Phase == "Bound", nil - - }); err != nil { + }, ctx.Done()) + if err != nil { r.Log.Error(err, "Failed to bind OVA PVC to PV ") return - } return nil }