Skip to content

Commit a78083d

Browse files
authored
Introduce http config settings in Azure storage (#4581)
* Introduce `http` config settings in Azure storage Cortex v1.11.0 included thanos-io/thanos#3970, which added configuration options to Azure's http client and transport, replacing usage of `http.DefaultClient`. Unfortunately since Cortex was not setting this config, Cortex implicitly switched from `http.DefaultClient` to all empty values (e.g. `MaxIdleConns: 0` rather than 100). Introduce `http` config settings to Azure storage. This motivated moving `s3.HTTPConfig` into a new `pkg/storage/bucket/config` package, to allow `azure` and `s3` to share it. Also update the instructions for running the website to include installing `embedmd`. Signed-off-by: Andrew Seigner <[email protected]> * feedback: `config.HTTP` -> `http.Config` also back out changelog cleanup Signed-off-by: Andrew Seigner <[email protected]> * Back out accidental changelog addition Signed-off-by: Andrew Seigner <[email protected]>
1 parent 4474da8 commit a78083d

File tree

13 files changed

+543
-29
lines changed

13 files changed

+543
-29
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* [ENHANCEMENT] Upgraded Docker base images to `alpine:3.14`. #4514
1212
* [ENHANCEMENT] Updated Prometheus to latest. Includes changes from prometheus#9239, adding 15 new functions. Multiple TSDB bugfixes prometheus#9438 & prometheus#9381. #4524
1313
* [ENHANCEMENT] Query Frontend: Add setting `-frontend.forward-headers-list` in frontend to configure the set of headers from the requests to be forwarded to downstream requests. #4486
14+
* [ENHANCEMENT] Blocks storage: Add `-blocks-storage.azure.http.*`, `-alertmanager-storage.azure.http.*`, and `-ruler-storage.azure.http.*` to configure the Azure storage client. #4581
1415
* [BUGFIX] AlertManager: remove stale template files. #4495
1516
* [BUGFIX] Distributor: fix bug in query-exemplar where some results would get dropped. #4582
1617

docs/blocks-storage/querier.md

+40-2
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ blocks_storage:
278278
# CLI flag: -blocks-storage.s3.http.response-header-timeout
279279
[response_header_timeout: <duration> | default = 2m]
280280
281-
# If the client connects to S3 via HTTPS and this option is enabled, the
282-
# client will accept any certificate and hostname.
281+
# If the client connects via HTTPS and this option is enabled, the client
282+
# will accept any certificate and hostname.
283283
# CLI flag: -blocks-storage.s3.http.insecure-skip-verify
284284
[insecure_skip_verify: <boolean> | default = false]
285285
@@ -340,6 +340,44 @@ blocks_storage:
340340
# CLI flag: -blocks-storage.azure.max-retries
341341
[max_retries: <int> | default = 20]
342342
343+
http:
344+
# The time an idle connection will remain idle before closing.
345+
# CLI flag: -blocks-storage.azure.http.idle-conn-timeout
346+
[idle_conn_timeout: <duration> | default = 1m30s]
347+
348+
# The amount of time the client will wait for a servers response headers.
349+
# CLI flag: -blocks-storage.azure.http.response-header-timeout
350+
[response_header_timeout: <duration> | default = 2m]
351+
352+
# If the client connects via HTTPS and this option is enabled, the client
353+
# will accept any certificate and hostname.
354+
# CLI flag: -blocks-storage.azure.http.insecure-skip-verify
355+
[insecure_skip_verify: <boolean> | default = false]
356+
357+
# Maximum time to wait for a TLS handshake. 0 means no limit.
358+
# CLI flag: -blocks-storage.azure.tls-handshake-timeout
359+
[tls_handshake_timeout: <duration> | default = 10s]
360+
361+
# The time to wait for a server's first response headers after fully
362+
# writing the request headers if the request has an Expect header. 0 to
363+
# send the request body immediately.
364+
# CLI flag: -blocks-storage.azure.expect-continue-timeout
365+
[expect_continue_timeout: <duration> | default = 1s]
366+
367+
# Maximum number of idle (keep-alive) connections across all hosts. 0
368+
# means no limit.
369+
# CLI flag: -blocks-storage.azure.max-idle-connections
370+
[max_idle_connections: <int> | default = 100]
371+
372+
# Maximum number of idle (keep-alive) connections to keep per-host. If 0,
373+
# a built-in default value is used.
374+
# CLI flag: -blocks-storage.azure.max-idle-connections-per-host
375+
[max_idle_connections_per_host: <int> | default = 100]
376+
377+
# Maximum number of connections per host. 0 means no limit.
378+
# CLI flag: -blocks-storage.azure.max-connections-per-host
379+
[max_connections_per_host: <int> | default = 0]
380+
343381
swift:
344382
# OpenStack Swift authentication API version. 0 to autodetect.
345383
# CLI flag: -blocks-storage.swift.auth-version

docs/blocks-storage/store-gateway.md

+40-2
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ blocks_storage:
342342
# CLI flag: -blocks-storage.s3.http.response-header-timeout
343343
[response_header_timeout: <duration> | default = 2m]
344344
345-
# If the client connects to S3 via HTTPS and this option is enabled, the
346-
# client will accept any certificate and hostname.
345+
# If the client connects via HTTPS and this option is enabled, the client
346+
# will accept any certificate and hostname.
347347
# CLI flag: -blocks-storage.s3.http.insecure-skip-verify
348348
[insecure_skip_verify: <boolean> | default = false]
349349
@@ -404,6 +404,44 @@ blocks_storage:
404404
# CLI flag: -blocks-storage.azure.max-retries
405405
[max_retries: <int> | default = 20]
406406
407+
http:
408+
# The time an idle connection will remain idle before closing.
409+
# CLI flag: -blocks-storage.azure.http.idle-conn-timeout
410+
[idle_conn_timeout: <duration> | default = 1m30s]
411+
412+
# The amount of time the client will wait for a servers response headers.
413+
# CLI flag: -blocks-storage.azure.http.response-header-timeout
414+
[response_header_timeout: <duration> | default = 2m]
415+
416+
# If the client connects via HTTPS and this option is enabled, the client
417+
# will accept any certificate and hostname.
418+
# CLI flag: -blocks-storage.azure.http.insecure-skip-verify
419+
[insecure_skip_verify: <boolean> | default = false]
420+
421+
# Maximum time to wait for a TLS handshake. 0 means no limit.
422+
# CLI flag: -blocks-storage.azure.tls-handshake-timeout
423+
[tls_handshake_timeout: <duration> | default = 10s]
424+
425+
# The time to wait for a server's first response headers after fully
426+
# writing the request headers if the request has an Expect header. 0 to
427+
# send the request body immediately.
428+
# CLI flag: -blocks-storage.azure.expect-continue-timeout
429+
[expect_continue_timeout: <duration> | default = 1s]
430+
431+
# Maximum number of idle (keep-alive) connections across all hosts. 0
432+
# means no limit.
433+
# CLI flag: -blocks-storage.azure.max-idle-connections
434+
[max_idle_connections: <int> | default = 100]
435+
436+
# Maximum number of idle (keep-alive) connections to keep per-host. If 0,
437+
# a built-in default value is used.
438+
# CLI flag: -blocks-storage.azure.max-idle-connections-per-host
439+
[max_idle_connections_per_host: <int> | default = 100]
440+
441+
# Maximum number of connections per host. 0 means no limit.
442+
# CLI flag: -blocks-storage.azure.max-connections-per-host
443+
[max_connections_per_host: <int> | default = 0]
444+
407445
swift:
408446
# OpenStack Swift authentication API version. 0 to autodetect.
409447
# CLI flag: -blocks-storage.swift.auth-version

docs/configuration/config-file-reference.md

+120-6
Original file line numberDiff line numberDiff line change
@@ -1714,8 +1714,8 @@ s3:
17141714
# CLI flag: -ruler-storage.s3.http.response-header-timeout
17151715
[response_header_timeout: <duration> | default = 2m]
17161716
1717-
# If the client connects to S3 via HTTPS and this option is enabled, the
1718-
# client will accept any certificate and hostname.
1717+
# If the client connects via HTTPS and this option is enabled, the client
1718+
# will accept any certificate and hostname.
17191719
# CLI flag: -ruler-storage.s3.http.insecure-skip-verify
17201720
[insecure_skip_verify: <boolean> | default = false]
17211721
@@ -1776,6 +1776,44 @@ azure:
17761776
# CLI flag: -ruler-storage.azure.max-retries
17771777
[max_retries: <int> | default = 20]
17781778
1779+
http:
1780+
# The time an idle connection will remain idle before closing.
1781+
# CLI flag: -ruler-storage.azure.http.idle-conn-timeout
1782+
[idle_conn_timeout: <duration> | default = 1m30s]
1783+
1784+
# The amount of time the client will wait for a servers response headers.
1785+
# CLI flag: -ruler-storage.azure.http.response-header-timeout
1786+
[response_header_timeout: <duration> | default = 2m]
1787+
1788+
# If the client connects via HTTPS and this option is enabled, the client
1789+
# will accept any certificate and hostname.
1790+
# CLI flag: -ruler-storage.azure.http.insecure-skip-verify
1791+
[insecure_skip_verify: <boolean> | default = false]
1792+
1793+
# Maximum time to wait for a TLS handshake. 0 means no limit.
1794+
# CLI flag: -ruler-storage.azure.tls-handshake-timeout
1795+
[tls_handshake_timeout: <duration> | default = 10s]
1796+
1797+
# The time to wait for a server's first response headers after fully writing
1798+
# the request headers if the request has an Expect header. 0 to send the
1799+
# request body immediately.
1800+
# CLI flag: -ruler-storage.azure.expect-continue-timeout
1801+
[expect_continue_timeout: <duration> | default = 1s]
1802+
1803+
# Maximum number of idle (keep-alive) connections across all hosts. 0 means
1804+
# no limit.
1805+
# CLI flag: -ruler-storage.azure.max-idle-connections
1806+
[max_idle_connections: <int> | default = 100]
1807+
1808+
# Maximum number of idle (keep-alive) connections to keep per-host. If 0, a
1809+
# built-in default value is used.
1810+
# CLI flag: -ruler-storage.azure.max-idle-connections-per-host
1811+
[max_idle_connections_per_host: <int> | default = 100]
1812+
1813+
# Maximum number of connections per host. 0 means no limit.
1814+
# CLI flag: -ruler-storage.azure.max-connections-per-host
1815+
[max_connections_per_host: <int> | default = 0]
1816+
17791817
swift:
17801818
# OpenStack Swift authentication API version. 0 to autodetect.
17811819
# CLI flag: -ruler-storage.swift.auth-version
@@ -2258,8 +2296,8 @@ s3:
22582296
# CLI flag: -alertmanager-storage.s3.http.response-header-timeout
22592297
[response_header_timeout: <duration> | default = 2m]
22602298
2261-
# If the client connects to S3 via HTTPS and this option is enabled, the
2262-
# client will accept any certificate and hostname.
2299+
# If the client connects via HTTPS and this option is enabled, the client
2300+
# will accept any certificate and hostname.
22632301
# CLI flag: -alertmanager-storage.s3.http.insecure-skip-verify
22642302
[insecure_skip_verify: <boolean> | default = false]
22652303
@@ -2320,6 +2358,44 @@ azure:
23202358
# CLI flag: -alertmanager-storage.azure.max-retries
23212359
[max_retries: <int> | default = 20]
23222360
2361+
http:
2362+
# The time an idle connection will remain idle before closing.
2363+
# CLI flag: -alertmanager-storage.azure.http.idle-conn-timeout
2364+
[idle_conn_timeout: <duration> | default = 1m30s]
2365+
2366+
# The amount of time the client will wait for a servers response headers.
2367+
# CLI flag: -alertmanager-storage.azure.http.response-header-timeout
2368+
[response_header_timeout: <duration> | default = 2m]
2369+
2370+
# If the client connects via HTTPS and this option is enabled, the client
2371+
# will accept any certificate and hostname.
2372+
# CLI flag: -alertmanager-storage.azure.http.insecure-skip-verify
2373+
[insecure_skip_verify: <boolean> | default = false]
2374+
2375+
# Maximum time to wait for a TLS handshake. 0 means no limit.
2376+
# CLI flag: -alertmanager-storage.azure.tls-handshake-timeout
2377+
[tls_handshake_timeout: <duration> | default = 10s]
2378+
2379+
# The time to wait for a server's first response headers after fully writing
2380+
# the request headers if the request has an Expect header. 0 to send the
2381+
# request body immediately.
2382+
# CLI flag: -alertmanager-storage.azure.expect-continue-timeout
2383+
[expect_continue_timeout: <duration> | default = 1s]
2384+
2385+
# Maximum number of idle (keep-alive) connections across all hosts. 0 means
2386+
# no limit.
2387+
# CLI flag: -alertmanager-storage.azure.max-idle-connections
2388+
[max_idle_connections: <int> | default = 100]
2389+
2390+
# Maximum number of idle (keep-alive) connections to keep per-host. If 0, a
2391+
# built-in default value is used.
2392+
# CLI flag: -alertmanager-storage.azure.max-idle-connections-per-host
2393+
[max_idle_connections_per_host: <int> | default = 100]
2394+
2395+
# Maximum number of connections per host. 0 means no limit.
2396+
# CLI flag: -alertmanager-storage.azure.max-connections-per-host
2397+
[max_connections_per_host: <int> | default = 0]
2398+
23232399
swift:
23242400
# OpenStack Swift authentication API version. 0 to autodetect.
23252401
# CLI flag: -alertmanager-storage.swift.auth-version
@@ -4565,8 +4641,8 @@ s3:
45654641
# CLI flag: -blocks-storage.s3.http.response-header-timeout
45664642
[response_header_timeout: <duration> | default = 2m]
45674643
4568-
# If the client connects to S3 via HTTPS and this option is enabled, the
4569-
# client will accept any certificate and hostname.
4644+
# If the client connects via HTTPS and this option is enabled, the client
4645+
# will accept any certificate and hostname.
45704646
# CLI flag: -blocks-storage.s3.http.insecure-skip-verify
45714647
[insecure_skip_verify: <boolean> | default = false]
45724648
@@ -4627,6 +4703,44 @@ azure:
46274703
# CLI flag: -blocks-storage.azure.max-retries
46284704
[max_retries: <int> | default = 20]
46294705
4706+
http:
4707+
# The time an idle connection will remain idle before closing.
4708+
# CLI flag: -blocks-storage.azure.http.idle-conn-timeout
4709+
[idle_conn_timeout: <duration> | default = 1m30s]
4710+
4711+
# The amount of time the client will wait for a servers response headers.
4712+
# CLI flag: -blocks-storage.azure.http.response-header-timeout
4713+
[response_header_timeout: <duration> | default = 2m]
4714+
4715+
# If the client connects via HTTPS and this option is enabled, the client
4716+
# will accept any certificate and hostname.
4717+
# CLI flag: -blocks-storage.azure.http.insecure-skip-verify
4718+
[insecure_skip_verify: <boolean> | default = false]
4719+
4720+
# Maximum time to wait for a TLS handshake. 0 means no limit.
4721+
# CLI flag: -blocks-storage.azure.tls-handshake-timeout
4722+
[tls_handshake_timeout: <duration> | default = 10s]
4723+
4724+
# The time to wait for a server's first response headers after fully writing
4725+
# the request headers if the request has an Expect header. 0 to send the
4726+
# request body immediately.
4727+
# CLI flag: -blocks-storage.azure.expect-continue-timeout
4728+
[expect_continue_timeout: <duration> | default = 1s]
4729+
4730+
# Maximum number of idle (keep-alive) connections across all hosts. 0 means
4731+
# no limit.
4732+
# CLI flag: -blocks-storage.azure.max-idle-connections
4733+
[max_idle_connections: <int> | default = 100]
4734+
4735+
# Maximum number of idle (keep-alive) connections to keep per-host. If 0, a
4736+
# built-in default value is used.
4737+
# CLI flag: -blocks-storage.azure.max-idle-connections-per-host
4738+
[max_idle_connections_per_host: <int> | default = 100]
4739+
4740+
# Maximum number of connections per host. 0 means no limit.
4741+
# CLI flag: -blocks-storage.azure.max-connections-per-host
4742+
[max_connections_per_host: <int> | default = 0]
4743+
46304744
swift:
46314745
# OpenStack Swift authentication API version. 0 to autodetect.
46324746
# CLI flag: -blocks-storage.swift.auth-version

docs/contributing/how-to-run-website-locally.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ The following initial setup is required only once:
1818
```
1919
cd website && npm install && cd -
2020
```
21-
4. Run `make BUILD_IN_CONTAINER=false web-build`
21+
4. Install [embedmd](https://github.com/campoy/embedmd) `v1.0.0`:
22+
```
23+
go install github.com/campoy/[email protected]
24+
```
25+
5. Run `make BUILD_IN_CONTAINER=false web-build`
2226

2327

2428
## Run it

pkg/storage/bucket/azure/bucket_client.go

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package azure
22

33
import (
44
"github.com/go-kit/log"
5+
"github.com/prometheus/common/model"
56
"github.com/thanos-io/thanos/pkg/objstore"
67
"github.com/thanos-io/thanos/pkg/objstore/azure"
78
yaml "gopkg.in/yaml.v2"
@@ -14,6 +15,16 @@ func NewBucketClient(cfg Config, name string, logger log.Logger) (objstore.Bucke
1415
ContainerName: cfg.ContainerName,
1516
Endpoint: cfg.Endpoint,
1617
MaxRetries: cfg.MaxRetries,
18+
HTTPConfig: azure.HTTPConfig{
19+
IdleConnTimeout: model.Duration(cfg.IdleConnTimeout),
20+
ResponseHeaderTimeout: model.Duration(cfg.ResponseHeaderTimeout),
21+
InsecureSkipVerify: cfg.InsecureSkipVerify,
22+
TLSHandshakeTimeout: model.Duration(cfg.TLSHandshakeTimeout),
23+
ExpectContinueTimeout: model.Duration(cfg.ExpectContinueTimeout),
24+
MaxIdleConns: cfg.MaxIdleConns,
25+
MaxIdleConnsPerHost: cfg.MaxIdleConnsPerHost,
26+
MaxConnsPerHost: cfg.MaxConnsPerHost,
27+
},
1728
}
1829

1930
// Thanos currently doesn't support passing the config as is, but expects a YAML,

pkg/storage/bucket/azure/config.go

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"flag"
55

66
"github.com/grafana/dskit/flagext"
7+
8+
"github.com/cortexproject/cortex/pkg/storage/bucket/http"
79
)
810

911
// Config holds the config options for an Azure backend
@@ -13,6 +15,8 @@ type Config struct {
1315
ContainerName string `yaml:"container_name"`
1416
Endpoint string `yaml:"endpoint_suffix"`
1517
MaxRetries int `yaml:"max_retries"`
18+
19+
http.Config `yaml:"http"`
1620
}
1721

1822
// RegisterFlags registers the flags for Azure storage
@@ -27,4 +31,5 @@ func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
2731
f.StringVar(&cfg.ContainerName, prefix+"azure.container-name", "", "Azure storage container name")
2832
f.StringVar(&cfg.Endpoint, prefix+"azure.endpoint-suffix", "", "Azure storage endpoint suffix without schema. The account name will be prefixed to this value to create the FQDN")
2933
f.IntVar(&cfg.MaxRetries, prefix+"azure.max-retries", 20, "Number of retries for recoverable errors")
34+
cfg.Config.RegisterFlagsWithPrefix(prefix+"azure.", f)
3035
}

0 commit comments

Comments
 (0)