client-go: make retry in Request thread safe

Kubernetes-commit: 6618b8ef7c0b552839555d4578b64427d20524ef
This commit is contained in:
Abu Kashem
2022-03-29 13:09:26 -04:00
committed by Kubernetes Publisher
parent 33011f1487
commit d8531f5ff0
3 changed files with 56 additions and 45 deletions

View File

@@ -52,12 +52,6 @@ var neverRetryError = IsRetryableErrorFunc(func(_ *http.Request, _ error) bool {
// Note that WithRetry is not safe for concurrent use by multiple
// goroutines without additional locking or coordination.
type WithRetry interface {
// SetMaxRetries makes the request use the specified integer as a ceiling
// for retries upon receiving a 429 status code and the "Retry-After" header
// in the response.
// A zero maxRetries should prevent from doing any retry and return immediately.
SetMaxRetries(maxRetries int)
// IsNextRetry advances the retry counter appropriately
// and returns true if the request should be retried,
// otherwise it returns false, if:
@@ -144,13 +138,6 @@ type withRetry struct {
previousErr, currentErr error
}
func (r *withRetry) SetMaxRetries(maxRetries int) {
if maxRetries < 0 {
maxRetries = 0
}
r.maxRetries = maxRetries
}
func (r *withRetry) trackPreviousError(err error) {
// keep track of two most recent errors
if r.currentErr != nil {