do not dump 2xx bodies in retry checker (#3332)
Don't dump the response body if there was no error as the requested data could be multiple GB in size in some cases #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🐛 Bugfix #### Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
eab5510c03
commit
ef2083bc20
@ -196,6 +196,10 @@ func (mw RetryMiddleware) Intercept(
|
||||
return resp, stackReq(ctx, req, resp, err)
|
||||
}
|
||||
|
||||
if resp != nil && resp.StatusCode/100 != 4 && resp.StatusCode/100 != 5 {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
exponentialBackOff := backoff.NewExponentialBackOff()
|
||||
exponentialBackOff.InitialInterval = mw.Delay
|
||||
exponentialBackOff.Reset()
|
||||
@ -313,6 +317,12 @@ func (mw RetryMiddleware) isRetriableRespCode(ctx context.Context, resp *http.Re
|
||||
return true
|
||||
}
|
||||
|
||||
// prevent the body dump below in case of a 2xx response.
|
||||
// There's no reason to check the body on a healthy status.
|
||||
if code/100 != 4 && code/100 != 5 {
|
||||
return false
|
||||
}
|
||||
|
||||
// not a status code, but the message itself might indicate a connectivity issue that
|
||||
// can be retried independent of the status code.
|
||||
return strings.Contains(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user