Skip to content

Commit

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

Signed-off-by: Tiger Kaovilai <[email protected]>
  • Loading branch information
kaovilai committed Mar 1, 2024
1 parent 0dbf0b0 commit f0075aa
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 @@ -2540,15 +2540,15 @@ func (ctx *restoreContext) processRecreateResourcePolicy(fromCluster, fromCluste
}

Check warning on line 2540 in pkg/restore/restore.go

View check run for this annotation

Codecov / codecov/patch

pkg/restore/restore.go#L2532-L2540

Added lines #L2532 - L2540 were not covered by tests
}
// 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

Check warning on line 2549 in pkg/restore/restore.go

View check run for this annotation

Codecov / codecov/patch

pkg/restore/restore.go#L2543-L2549

Added lines #L2543 - L2549 were not covered by tests
})

// Create object from latest backup/restore)
obj.SetNamespace(namespace)
_, err = resourceClient.Create(obj)
Expand Down

0 comments on commit f0075aa

Please sign in to comment.