From 63b3e4e5ec580e1a2f84fc6e84be14b5cdb03c09 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Sun, 26 Sep 2021 23:16:12 +0200 Subject: [PATCH] Enable HTTP2 again (#9398) We are re-enabling HTTP 2 again. There has been a few bugfixes upstream in go, and we have also enabled ReadIdleTimeout. Fix #7588 Fix #9068 Signed-off-by: Julien Pivotto --- discovery/consul/consul.go | 2 +- discovery/digitalocean/digitalocean.go | 2 +- discovery/eureka/eureka.go | 2 +- discovery/hetzner/hcloud.go | 2 +- discovery/hetzner/robot.go | 2 +- discovery/http/http.go | 2 +- discovery/kubernetes/kubernetes.go | 2 +- discovery/linode/linode.go | 2 +- discovery/marathon/marathon.go | 2 +- discovery/moby/docker.go | 2 +- discovery/moby/dockerswarm.go | 2 +- discovery/puppetdb/puppetdb.go | 2 +- discovery/scaleway/baremetal.go | 2 +- discovery/scaleway/instance.go | 2 +- discovery/xds/client.go | 2 +- go.mod | 2 +- go.sum | 3 ++- notifier/notifier.go | 2 +- notifier/notifier_test.go | 2 +- scrape/scrape.go | 4 ++-- scrape/target_test.go | 16 ++++++++-------- storage/remote/client.go | 4 ++-- 22 files changed, 32 insertions(+), 31 deletions(-) diff --git a/discovery/consul/consul.go b/discovery/consul/consul.go index 19dc9ecca..16d0d2628 100644 --- a/discovery/consul/consul.go +++ b/discovery/consul/consul.go @@ -199,7 +199,7 @@ func NewDiscovery(conf *SDConfig, logger log.Logger) (*Discovery, error) { logger = log.NewNopLogger() } - wrapper, err := config.NewClientFromConfig(conf.HTTPClientConfig, "consul_sd", config.WithHTTP2Disabled(), config.WithIdleConnTimeout(2*watchTimeout)) + wrapper, err := config.NewClientFromConfig(conf.HTTPClientConfig, "consul_sd", config.WithIdleConnTimeout(2*watchTimeout)) if err != nil { return nil, err } diff --git a/discovery/digitalocean/digitalocean.go b/discovery/digitalocean/digitalocean.go index b887ada04..10f8582eb 100644 --- a/discovery/digitalocean/digitalocean.go +++ b/discovery/digitalocean/digitalocean.go @@ -108,7 +108,7 @@ func NewDiscovery(conf *SDConfig, logger log.Logger) (*Discovery, error) { port: conf.Port, } - rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "digitalocean_sd", config.WithHTTP2Disabled()) + rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "digitalocean_sd") if err != nil { return nil, err } diff --git a/discovery/eureka/eureka.go b/discovery/eureka/eureka.go index dcfc2be10..110a5d862 100644 --- a/discovery/eureka/eureka.go +++ b/discovery/eureka/eureka.go @@ -118,7 +118,7 @@ type Discovery struct { // NewDiscovery creates a new Eureka discovery for the given role. func NewDiscovery(conf *SDConfig, logger log.Logger) (*Discovery, error) { - rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "eureka_sd", config.WithHTTP2Disabled()) + rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "eureka_sd") if err != nil { return nil, err } diff --git a/discovery/hetzner/hcloud.go b/discovery/hetzner/hcloud.go index 494321fd5..35492e6a0 100644 --- a/discovery/hetzner/hcloud.go +++ b/discovery/hetzner/hcloud.go @@ -64,7 +64,7 @@ func newHcloudDiscovery(conf *SDConfig, logger log.Logger) (*hcloudDiscovery, er port: conf.Port, } - rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "hetzner_sd", config.WithHTTP2Disabled()) + rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "hetzner_sd") if err != nil { return nil, err } diff --git a/discovery/hetzner/robot.go b/discovery/hetzner/robot.go index f7079d909..25f04502f 100644 --- a/discovery/hetzner/robot.go +++ b/discovery/hetzner/robot.go @@ -59,7 +59,7 @@ func newRobotDiscovery(conf *SDConfig, logger log.Logger) (*robotDiscovery, erro endpoint: conf.robotEndpoint, } - rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "hetzner_sd", config.WithHTTP2Disabled()) + rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "hetzner_sd") if err != nil { return nil, err } diff --git a/discovery/http/http.go b/discovery/http/http.go index af2e99939..ee3643fdb 100644 --- a/discovery/http/http.go +++ b/discovery/http/http.go @@ -113,7 +113,7 @@ func NewDiscovery(conf *SDConfig, logger log.Logger) (*Discovery, error) { logger = log.NewNopLogger() } - client, err := config.NewClientFromConfig(conf.HTTPClientConfig, "http", config.WithHTTP2Disabled()) + client, err := config.NewClientFromConfig(conf.HTTPClientConfig, "http") if err != nil { return nil, err } diff --git a/discovery/kubernetes/kubernetes.go b/discovery/kubernetes/kubernetes.go index 3a02922a4..a87203e4e 100644 --- a/discovery/kubernetes/kubernetes.go +++ b/discovery/kubernetes/kubernetes.go @@ -283,7 +283,7 @@ func New(l log.Logger, conf *SDConfig) (*Discovery, error) { } level.Info(l).Log("msg", "Using pod service account via in-cluster config") } else { - rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "kubernetes_sd", config.WithHTTP2Disabled()) + rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "kubernetes_sd") if err != nil { return nil, err } diff --git a/discovery/linode/linode.go b/discovery/linode/linode.go index 21c856857..fad2a74f1 100644 --- a/discovery/linode/linode.go +++ b/discovery/linode/linode.go @@ -132,7 +132,7 @@ func NewDiscovery(conf *SDConfig, logger log.Logger) (*Discovery, error) { eventPollingEnabled: true, } - rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "linode_sd", config.WithHTTP2Disabled()) + rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "linode_sd") if err != nil { return nil, err } diff --git a/discovery/marathon/marathon.go b/discovery/marathon/marathon.go index 586245bc4..30c32bb5d 100644 --- a/discovery/marathon/marathon.go +++ b/discovery/marathon/marathon.go @@ -131,7 +131,7 @@ type Discovery struct { // NewDiscovery returns a new Marathon Discovery. func NewDiscovery(conf SDConfig, logger log.Logger) (*Discovery, error) { - rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "marathon_sd", config.WithHTTP2Disabled()) + rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "marathon_sd") if err != nil { return nil, err } diff --git a/discovery/moby/docker.go b/discovery/moby/docker.go index 98dc42acb..deabcdd1e 100644 --- a/discovery/moby/docker.go +++ b/discovery/moby/docker.go @@ -142,7 +142,7 @@ func NewDockerDiscovery(conf *DockerSDConfig, logger log.Logger) (*DockerDiscove // unix, which are not supported by the HTTP client. Passing HTTP client // options to the Docker client makes those non-HTTP requests fail. if hostURL.Scheme == "http" || hostURL.Scheme == "https" { - rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "docker_sd", config.WithHTTP2Disabled()) + rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "docker_sd") if err != nil { return nil, err } diff --git a/discovery/moby/dockerswarm.go b/discovery/moby/dockerswarm.go index a9eabfd72..371f9d5ed 100644 --- a/discovery/moby/dockerswarm.go +++ b/discovery/moby/dockerswarm.go @@ -146,7 +146,7 @@ func NewDiscovery(conf *DockerSwarmSDConfig, logger log.Logger) (*Discovery, err // unix, which are not supported by the HTTP client. Passing HTTP client // options to the Docker client makes those non-HTTP requests fail. if hostURL.Scheme == "http" || hostURL.Scheme == "https" { - rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "dockerswarm_sd", config.WithHTTP2Disabled()) + rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "dockerswarm_sd") if err != nil { return nil, err } diff --git a/discovery/puppetdb/puppetdb.go b/discovery/puppetdb/puppetdb.go index cad07b33d..c6e93ebe9 100644 --- a/discovery/puppetdb/puppetdb.go +++ b/discovery/puppetdb/puppetdb.go @@ -136,7 +136,7 @@ func NewDiscovery(conf *SDConfig, logger log.Logger) (*Discovery, error) { logger = log.NewNopLogger() } - client, err := config.NewClientFromConfig(conf.HTTPClientConfig, "http", config.WithHTTP2Disabled()) + client, err := config.NewClientFromConfig(conf.HTTPClientConfig, "http") if err != nil { return nil, err } diff --git a/discovery/scaleway/baremetal.go b/discovery/scaleway/baremetal.go index 066c0b604..9e002b987 100644 --- a/discovery/scaleway/baremetal.go +++ b/discovery/scaleway/baremetal.go @@ -70,7 +70,7 @@ func newBaremetalDiscovery(conf *SDConfig) (*baremetalDiscovery, error) { tagsFilter: conf.TagsFilter, } - rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "scaleway_sd", config.WithHTTP2Disabled()) + rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "scaleway_sd") if err != nil { return nil, err } diff --git a/discovery/scaleway/instance.go b/discovery/scaleway/instance.go index 8b2603165..a78c5e93c 100644 --- a/discovery/scaleway/instance.go +++ b/discovery/scaleway/instance.go @@ -81,7 +81,7 @@ func newInstanceDiscovery(conf *SDConfig) (*instanceDiscovery, error) { tagsFilter: conf.TagsFilter, } - rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "scaleway_sd", config.WithHTTP2Disabled()) + rt, err := config.NewRoundTripperFromConfig(conf.HTTPClientConfig, "scaleway_sd") if err != nil { return nil, err } diff --git a/discovery/xds/client.go b/discovery/xds/client.go index cd8ffb017..05d1ca40c 100644 --- a/discovery/xds/client.go +++ b/discovery/xds/client.go @@ -112,7 +112,7 @@ func NewHTTPResourceClient(conf *HTTPResourceClientConfig, protocolVersion Proto endpointURL.RawQuery = conf.ExtraQueryParams.Encode() } - client, err := config.NewClientFromConfig(conf.HTTPClientConfig, conf.Name, config.WithHTTP2Disabled(), config.WithIdleConnTimeout(conf.Timeout)) + client, err := config.NewClientFromConfig(conf.HTTPClientConfig, conf.Name, config.WithIdleConnTimeout(conf.Timeout)) if err != nil { return nil, err } diff --git a/go.mod b/go.mod index 8445c6df4..3830b553a 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,7 @@ require ( github.com/prometheus/alertmanager v0.23.0 github.com/prometheus/client_golang v1.11.0 github.com/prometheus/client_model v0.2.0 - github.com/prometheus/common v0.30.0 + github.com/prometheus/common v0.31.0 github.com/prometheus/common/sigv4 v0.1.0 github.com/prometheus/exporter-toolkit v0.6.1 github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210223165440-c65ae3540d44 diff --git a/go.sum b/go.sum index 28dab20d8..71a26a26b 100644 --- a/go.sum +++ b/go.sum @@ -1140,8 +1140,9 @@ github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8b github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.30.0 h1:JEkYlQnpzrzQFxi6gnukFPdQ+ac82oRhzMcIduJu/Ug= github.com/prometheus/common v0.30.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.31.0 h1:FTJdLTjtrh4dXlCjpzdZJXMnejSTL5F/nVQm5sNwD34= +github.com/prometheus/common v0.31.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4= github.com/prometheus/common/sigv4 v0.1.0/go.mod h1:2Jkxxk9yYvCkE5G1sQT7GuEXm57JrvHu9k5YwTjsNtI= github.com/prometheus/exporter-toolkit v0.6.1 h1:Aqk75wQD92N9CqmTlZwjKwq6272nOGrWIbc8Z7+xQO0= diff --git a/notifier/notifier.go b/notifier/notifier.go index 7af21c565..97086d562 100644 --- a/notifier/notifier.go +++ b/notifier/notifier.go @@ -634,7 +634,7 @@ type alertmanagerSet struct { } func newAlertmanagerSet(cfg *config.AlertmanagerConfig, logger log.Logger, metrics *alertMetrics) (*alertmanagerSet, error) { - client, err := config_util.NewClientFromConfig(cfg.HTTPClientConfig, "alertmanager", config_util.WithHTTP2Disabled()) + client, err := config_util.NewClientFromConfig(cfg.HTTPClientConfig, "alertmanager") if err != nil { return nil, err } diff --git a/notifier/notifier_test.go b/notifier/notifier_test.go index 0b7d8e089..e4a7f26cd 100644 --- a/notifier/notifier_test.go +++ b/notifier/notifier_test.go @@ -154,7 +154,7 @@ func TestHandlerSendAll(t *testing.T) { Username: "prometheus", Password: "testing_password", }, - }, "auth_alertmanager", config_util.WithHTTP2Disabled()) + }, "auth_alertmanager") h.alertmanagers = make(map[string]*alertmanagerSet) diff --git a/scrape/scrape.go b/scrape/scrape.go index 1a152323b..f3622cf2e 100644 --- a/scrape/scrape.go +++ b/scrape/scrape.go @@ -269,7 +269,7 @@ func newScrapePool(cfg *config.ScrapeConfig, app storage.Appendable, jitterSeed logger = log.NewNopLogger() } - client, err := config_util.NewClientFromConfig(cfg.HTTPClientConfig, cfg.JobName, config_util.WithHTTP2Disabled()) + client, err := config_util.NewClientFromConfig(cfg.HTTPClientConfig, cfg.JobName) if err != nil { targetScrapePoolsFailed.Inc() return nil, errors.Wrap(err, "error creating HTTP client") @@ -380,7 +380,7 @@ func (sp *scrapePool) reload(cfg *config.ScrapeConfig) error { targetScrapePoolReloads.Inc() start := time.Now() - client, err := config_util.NewClientFromConfig(cfg.HTTPClientConfig, cfg.JobName, config_util.WithHTTP2Disabled()) + client, err := config_util.NewClientFromConfig(cfg.HTTPClientConfig, cfg.JobName) if err != nil { targetScrapePoolReloadsFailed.Inc() return errors.Wrap(err, "error creating HTTP client") diff --git a/scrape/target_test.go b/scrape/target_test.go index d17dcc314..a578d2760 100644 --- a/scrape/target_test.go +++ b/scrape/target_test.go @@ -149,7 +149,7 @@ func TestNewHTTPBearerToken(t *testing.T) { cfg := config_util.HTTPClientConfig{ BearerToken: "1234", } - c, err := config_util.NewClientFromConfig(cfg, "test", config_util.WithHTTP2Disabled()) + c, err := config_util.NewClientFromConfig(cfg, "test") if err != nil { t.Fatal(err) } @@ -176,7 +176,7 @@ func TestNewHTTPBearerTokenFile(t *testing.T) { cfg := config_util.HTTPClientConfig{ BearerTokenFile: "testdata/bearertoken.txt", } - c, err := config_util.NewClientFromConfig(cfg, "test", config_util.WithHTTP2Disabled()) + c, err := config_util.NewClientFromConfig(cfg, "test") if err != nil { t.Fatal(err) } @@ -205,7 +205,7 @@ func TestNewHTTPBasicAuth(t *testing.T) { Password: "password123", }, } - c, err := config_util.NewClientFromConfig(cfg, "test", config_util.WithHTTP2Disabled()) + c, err := config_util.NewClientFromConfig(cfg, "test") if err != nil { t.Fatal(err) } @@ -233,7 +233,7 @@ func TestNewHTTPCACert(t *testing.T) { CAFile: caCertPath, }, } - c, err := config_util.NewClientFromConfig(cfg, "test", config_util.WithHTTP2Disabled()) + c, err := config_util.NewClientFromConfig(cfg, "test") if err != nil { t.Fatal(err) } @@ -266,7 +266,7 @@ func TestNewHTTPClientCert(t *testing.T) { KeyFile: "testdata/client.key", }, } - c, err := config_util.NewClientFromConfig(cfg, "test", config_util.WithHTTP2Disabled()) + c, err := config_util.NewClientFromConfig(cfg, "test") if err != nil { t.Fatal(err) } @@ -295,7 +295,7 @@ func TestNewHTTPWithServerName(t *testing.T) { ServerName: "prometheus.rocks", }, } - c, err := config_util.NewClientFromConfig(cfg, "test", config_util.WithHTTP2Disabled()) + c, err := config_util.NewClientFromConfig(cfg, "test") if err != nil { t.Fatal(err) } @@ -324,7 +324,7 @@ func TestNewHTTPWithBadServerName(t *testing.T) { ServerName: "badname", }, } - c, err := config_util.NewClientFromConfig(cfg, "test", config_util.WithHTTP2Disabled()) + c, err := config_util.NewClientFromConfig(cfg, "test") if err != nil { t.Fatal(err) } @@ -362,7 +362,7 @@ func TestNewClientWithBadTLSConfig(t *testing.T) { KeyFile: "testdata/nonexistent_client.key", }, } - _, err := config_util.NewClientFromConfig(cfg, "test", config_util.WithHTTP2Disabled()) + _, err := config_util.NewClientFromConfig(cfg, "test") if err == nil { t.Fatalf("Expected error, got nil.") } diff --git a/storage/remote/client.go b/storage/remote/client.go index 2d6c5a10a..7539c2c92 100644 --- a/storage/remote/client.go +++ b/storage/remote/client.go @@ -110,7 +110,7 @@ type ReadClient interface { // NewReadClient creates a new client for remote read. func NewReadClient(name string, conf *ClientConfig) (ReadClient, error) { - httpClient, err := config_util.NewClientFromConfig(conf.HTTPClientConfig, "remote_storage_read_client", config_util.WithHTTP2Disabled()) + httpClient, err := config_util.NewClientFromConfig(conf.HTTPClientConfig, "remote_storage_read_client") if err != nil { return nil, err } @@ -136,7 +136,7 @@ func NewReadClient(name string, conf *ClientConfig) (ReadClient, error) { // NewWriteClient creates a new client for remote write. func NewWriteClient(name string, conf *ClientConfig) (WriteClient, error) { - httpClient, err := config_util.NewClientFromConfig(conf.HTTPClientConfig, "remote_storage_write_client", config_util.WithHTTP2Disabled()) + httpClient, err := config_util.NewClientFromConfig(conf.HTTPClientConfig, "remote_storage_write_client") if err != nil { return nil, err }