Skip to content

Commit

Permalink
use wait.PollImmediate
Browse files Browse the repository at this point in the history
addresses vmware-tanzu#6354 (review)

Signed-off-by: Tiger Kaovilai <[email protected]>
  • Loading branch information
kaovilai committed Aug 2, 2023
1 parent b635e85 commit 6e25841
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6e25841

Please sign in to comment.