Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "http: read on closed response body" error #8332

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions cmd/lakectl/cmd/retry_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"crypto/x509"
"errors"
"io"
"net/http"
"net/url"
"regexp"
Expand All @@ -17,10 +16,6 @@ var (
redirectsErrorRe = regexp.MustCompile(`stopped after \d+ redirects\z`)
schemeErrorRe = regexp.MustCompile(`unsupported protocol scheme`)
notTrustedErrorRe = regexp.MustCompile(`certificate is not trusted`)

// We need to consume response bodies to maintain http connections, but
// limit the size we consume to respReadLimit.
respReadLimit = int64(4096) //nolint:mnd
)

func NewRetryClient(retriesCfg RetriesCfg, transport *http.Transport) *http.Client {
Expand All @@ -33,7 +28,6 @@ func NewRetryClient(retriesCfg RetriesCfg, transport *http.Transport) *http.Clie
retryClient.RetryWaitMin = retriesCfg.MinWaitInterval
retryClient.RetryWaitMax = retriesCfg.MaxWaitInterval
retryClient.CheckRetry = lakectlRetryPolicy
retryClient.ErrorHandler = customErrorHandler
return retryClient.StandardClient()
}

Expand Down Expand Up @@ -77,11 +71,3 @@ func lakectlRetryPolicy(ctx context.Context, resp *http.Response, err error) (bo
}
return false, nil
}

func customErrorHandler(resp *http.Response, err error, _ int) (*http.Response, error) {
if resp != nil {
defer resp.Body.Close()
io.Copy(io.Discard, io.LimitReader(resp.Body, respReadLimit)) //nolint:errcheck
}
return resp, err
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
It looks like endpoint url is wrong.
Get "/wrong_uri/repositories": unsupported protocol scheme ""
Get "/wrong_uri/repositories": GET /wrong_uri/repositories giving up after 1 attempt(s): unsupported protocol scheme ""
Suspicious URI format for server.endpoint_url: wrong_uri
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Trying to run a sanity command using current configuration.
Got error while trying to run a sanity command.
Trying to analyze error.
It looks like endpoint url is wrong.
Get "/wrong_uri/repositories": unsupported protocol scheme ""
Get "/wrong_uri/repositories": GET /wrong_uri/repositories giving up after 1 attempt(s): unsupported protocol scheme ""
Trying to validate access key format.
Couldn't find a problem with access key format.
Trying to validate secret access key format.
Expand Down
Loading