From 2c59b8482fa51060c441326a8f134da63e8e4131 Mon Sep 17 00:00:00 2001 From: Ricardo Maraschini Date: Wed, 2 Jun 2021 13:46:58 +0200 Subject: [PATCH] Using http.DefaultTransport timeouts Using the very same timeouts present on http.DefaultTransport into our custom http client Transport. --- pkg/storage/s3/s3.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/storage/s3/s3.go b/pkg/storage/s3/s3.go index 84972db0e6..ada1e56355 100644 --- a/pkg/storage/s3/s3.go +++ b/pkg/storage/s3/s3.go @@ -3,9 +3,11 @@ package s3 import ( "context" "fmt" + "net" "net/http" "net/url" "reflect" + "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -143,6 +145,16 @@ func (d *driver) getS3Service() (*s3.S3, error) { Region: &d.Config.Region, HTTPClient: &http.Client{ Transport: &http.Transport{ + DialContext: (&net.Dialer{ + Timeout: 30 * time.Second, + KeepAlive: 30 * time.Second, + DualStack: true, + }).DialContext, + ForceAttemptHTTP2: true, + MaxIdleConns: 100, + IdleConnTimeout: 90 * time.Second, + TLSHandshakeTimeout: 10 * time.Second, + ExpectContinueTimeout: 1 * time.Second, Proxy: func(req *http.Request) (*url.URL, error) { return httpproxy.FromEnvironment().ProxyFunc()(req.URL) },