Skip to content

Commit

Permalink
update to design vmware-tanzu#8063
Browse files Browse the repository at this point in the history
Signed-off-by: Tiger Kaovilai <[email protected]>
  • Loading branch information
kaovilai committed Sep 9, 2024
1 parent 7a73d1c commit 77c15d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pkg/client/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ func CapBackoff(cap time.Duration) wait.Backoff {
}
}

// RetriesPhasePatchFunc accepts a patch function param, retrying when the provided retriable function returns true.
func RetriesPhasePatchFunc(maxDuration time.Duration, fn func() error, retriable func(error) bool) error {
// RetryOnRetriableMaxBackOff accepts a patch function param, retrying when the provided retriable function returns true.
func RetryOnRetriableMaxBackOff(maxDuration time.Duration, fn func() error, retriable func(error) bool) error {
return retry.OnError(CapBackoff(maxDuration), func(err error) bool { return retriable(err) }, fn)
}

// RetriesPhasePatchFuncOnErrors accepts a patch function param, retrying when the error is not nil.
func RetriesPhasePatchFuncOnErrors(maxDuration time.Duration, fn func() error) error {
return RetriesPhasePatchFunc(maxDuration, fn, func(err error) bool { return err != nil })
// RetryOnErrorMaxBackOff accepts a patch function param, retrying when the error is not nil.
func RetryOnErrorMaxBackOff(maxDuration time.Duration, fn func() error) error {
return RetryOnRetriableMaxBackOff(maxDuration, fn, func(err error) bool { return err != nil })
}
2 changes: 1 addition & 1 deletion pkg/util/kube/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func PatchResource(original, updated client.Object, kbClient client.Client) erro

// PatchResourceWithRetries patches the original resource with the updated resource, retrying when the provided retriable function returns true.
func PatchResourceWithRetries(maxDuration time.Duration, original, updated client.Object, kbClient client.Client, retriable func(error) bool) error {
return veleroPkgClient.RetriesPhasePatchFunc(maxDuration, func() error { return PatchResource(original, updated, kbClient) }, retriable)
return veleroPkgClient.RetryOnRetriableMaxBackOff(maxDuration, func() error { return PatchResource(original, updated, kbClient) }, retriable)
}

// PatchResourceWithRetriesOnErrors patches the original resource with the updated resource, retrying when the operation returns an error.
Expand Down

0 comments on commit 77c15d1

Please sign in to comment.