Skip to content

Commit

Permalink
Make sure we close the response body before retrying
Browse files Browse the repository at this point in the history
Not doing so can keep the HTTP client code waiting forever,
keeping some goroutines running, and the socket open.

Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Apr 5, 2024
1 parent 489cf63 commit 77f9d7b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions docker/docker_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ func (c *dockerClient) makeRequestToResolvedURL(ctx context.Context, method stri
if attempts == 1 && stream == nil && auth != noAuth {
if retry, newScope := needsRetryWithUpdatedScope(res); retry {
logrus.Debug("Detected insufficient_scope error, will retry request with updated scope")
res.Body.Close()
// Note: This retry ignores extraScope. That’s, strictly speaking, incorrect, but we don’t currently
// expect the insufficient_scope errors to happen for those callers. If that changes, we can add support
// for more than one extra scope.
Expand Down

0 comments on commit 77f9d7b

Please sign in to comment.