From 0997191b182bc40a1e050856084fe9b8dc46f523 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 5 Oct 2017 12:32:24 +0100 Subject: [PATCH] Port 'Don't disable HTTP keep-alives for remote storage connections.' to 2.0 (see #3173) Removes configurability introduced in #3160 in favour of hard-coding, per advice from @brian-brazil. --- storage/remote/client.go | 2 +- util/httputil/client.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/storage/remote/client.go b/storage/remote/client.go index 421506382..79ccb5910 100644 --- a/storage/remote/client.go +++ b/storage/remote/client.go @@ -55,7 +55,7 @@ type ClientConfig struct { // NewClient creates a new Client. func NewClient(index int, conf *ClientConfig) (*Client, error) { - httpClient, err := httputil.NewClientFromConfig(conf.HTTPClientConfig, "remote_storage") + httpClient, err := httputil.NewClientFromConfigAndOptions(conf.HTTPClientConfig, "remote_storage", false) if err != nil { return nil, err } diff --git a/util/httputil/client.go b/util/httputil/client.go index e36e35361..bed76b243 100644 --- a/util/httputil/client.go +++ b/util/httputil/client.go @@ -34,6 +34,12 @@ func newClient(rt http.RoundTripper) *http.Client { // NewClientFromConfig returns a new HTTP client configured for the // given config.HTTPClientConfig. The name is used as go-conntrack metric label. func NewClientFromConfig(cfg config.HTTPClientConfig, name string) (*http.Client, error) { + return NewClientFromConfigAndOptions(cfg, name, true) +} + +// NewClientFromConfigAndOptions returns a new HTTP client configured for the +// given config.HTTPClientConfig. The name is used as go-conntrack metric label. +func NewClientFromConfigAndOptions(cfg config.HTTPClientConfig, name string, disableKeepAlives bool) (*http.Client, error) { tlsConfig, err := NewTLSConfig(cfg.TLSConfig) if err != nil { return nil, err @@ -43,7 +49,7 @@ func NewClientFromConfig(cfg config.HTTPClientConfig, name string) (*http.Client var rt http.RoundTripper = &http.Transport{ Proxy: http.ProxyURL(cfg.ProxyURL.URL), MaxIdleConns: 20000, - DisableKeepAlives: false, + DisableKeepAlives: disableKeepAlives, TLSClientConfig: tlsConfig, DisableCompression: true, // 5 minutes is typically above the maximum sane scrape interval. So we can