diff --git a/pkg/restore/restore.go b/pkg/restore/restore.go index 43635e0c95..61ed50803e 100644 --- a/pkg/restore/restore.go +++ b/pkg/restore/restore.go @@ -2232,15 +2232,15 @@ func (ctx *restoreContext) processRecreateResourcePolicy(fromCluster, fromCluste } } // wait up to 2 minutes until object does not exists in cluster - for timeStarted := time.Now(); apierrors.IsNotFound(err) || time.Now().After(timeStarted.Add(2*time.Minute)); { + wait.PollImmediate(5*time.Second, 2*time.Minute, func() (bool, error) { _, err = resourceClient.Get(obj.GetName(), metav1.GetOptions{}) if !apierrors.IsNotFound(err) { - ctx.log.Warnf("get attempt to check object is gone failed for %s %s: %v", fromCluster.GroupVersionKind(), kube.NamespaceAndName(fromCluster), err) - time.Sleep(10 * time.Second) - continue + ctx.log.Infof("waiting until %s %s IsNotFound for recreate existingResourcePolicy. current err from get: %v", fromCluster.GroupVersionKind(), kube.NamespaceAndName(fromCluster), err) + return false, nil } - break - } + return true, nil + }) + // Create object from latest backup/restore) obj.SetNamespace(namespace) _, err = resourceClient.Create(obj)