diff --git a/cmd/activator/main.go b/cmd/activator/main.go index 44220053f083..e55a2c66a7b8 100644 --- a/cmd/activator/main.go +++ b/cmd/activator/main.go @@ -104,6 +104,14 @@ func (rrt *retryRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) break } + // stop retrying if the maximum elapsed time would be exceeded after + // the next timeout + nextDelay := rrt.CalculateDelay(retries, minRetryInterval) + elapsedTime := time.Now().Sub(startTime) + if elapsedTime+nextDelay > maxRetryTime { + break + } + if err != nil { rrt.logger.Errorf("Error making a request: %s", err) } @@ -112,14 +120,6 @@ func (rrt *retryRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) resp.Body.Close() } - // stop retrying if the maximum elapsed time would be exceeded after - // the next timeout - nextDelay := rrt.CalculateDelay(retries, minRetryInterval) - elapsedTime := time.Now().Sub(startTime) - if elapsedTime+maxRetryTime > maxRetryTime { - break - } - time.Sleep(nextDelay) // The request body cannot be read multiple times for retries.