Skip to content

Commit

Permalink
fix(compute/metadata): close Response Body for failed request (#10891)
Browse files Browse the repository at this point in the history
  • Loading branch information
guymaor-google authored Sep 20, 2024
1 parent ac256c5 commit e91d45e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compute/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ func (c *Client) getETag(ctx context.Context, suffix string) (value, etag string
code = res.StatusCode
}
if delay, shouldRetry := retryer.Retry(code, reqErr); shouldRetry {
if res != nil && res.Body != nil {
res.Body.Close()
}
if err := sleep(ctx, delay); err != nil {
return "", "", err
}
Expand Down

0 comments on commit e91d45e

Please sign in to comment.