Skip to content

Commit cb0d7f4

Browse files
committed
chore: add GCS HTTP config
1 parent f0cd146 commit cb0d7f4

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed

Diff for: docs/sources/configure-server/reference-configuration-parameters/index.md

+38
Original file line numberDiff line numberDiff line change
@@ -2356,6 +2356,44 @@ The gcs_backend block configures the connection to Google Cloud Storage object s
23562356
# 3. On Google Compute Engine it fetches credentials from the metadata server.
23572357
# CLI flag: -storage.gcs.service-account
23582358
[service_account: <string> | default = ""]
2359+
2360+
http:
2361+
# The time an idle connection will remain idle before closing.
2362+
# CLI flag: -storage.gcs.http.idle-conn-timeout
2363+
[idle_conn_timeout: <duration> | default = 1m30s]
2364+
2365+
# The amount of time the client will wait for a servers response headers.
2366+
# CLI flag: -storage.gcs.http.response-header-timeout
2367+
[response_header_timeout: <duration> | default = 2m]
2368+
2369+
# If the client connects to GCS via HTTPS and this option is enabled, the
2370+
# client will accept any certificate and hostname.
2371+
# CLI flag: -storage.gcs.http.insecure-skip-verify
2372+
[insecure_skip_verify: <boolean> | default = false]
2373+
2374+
# Maximum time to wait for a TLS handshake. 0 means no limit.
2375+
# CLI flag: -storage.gcs.tls-handshake-timeout
2376+
[tls_handshake_timeout: <duration> | default = 10s]
2377+
2378+
# The time to wait for a server's first response headers after fully writing
2379+
# the request headers if the request has an Expect header. 0 to send the
2380+
# request body immediately.
2381+
# CLI flag: -storage.gcs.expect-continue-timeout
2382+
[expect_continue_timeout: <duration> | default = 1s]
2383+
2384+
# Maximum number of idle (keep-alive) connections across all hosts. 0 means no
2385+
# limit.
2386+
# CLI flag: -storage.gcs.max-idle-connections
2387+
[max_idle_conns: <int> | default = 0]
2388+
2389+
# Maximum number of idle (keep-alive) connections to keep per-host. If 0, a
2390+
# built-in default value is used.
2391+
# CLI flag: -storage.gcs.max-idle-connections-per-host
2392+
[max_idle_conns_per_host: <int> | default = 100]
2393+
2394+
# Maximum number of connections per host. 0 means no limit.
2395+
# CLI flag: -storage.gcs.max-connections-per-host
2396+
[max_conns_per_host: <int> | default = 0]
23592397
```
23602398
23612399
### azure_storage_backend

Diff for: pkg/objstore/providers/gcs/bucket_client.go

+12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import (
99
"context"
1010

1111
"github.com/go-kit/log"
12+
"github.com/prometheus/common/model"
1213
"github.com/thanos-io/objstore"
14+
"github.com/thanos-io/objstore/exthttp"
1315
"github.com/thanos-io/objstore/providers/gcs"
1416
"gopkg.in/yaml.v3"
1517
)
@@ -19,6 +21,16 @@ func NewBucketClient(ctx context.Context, cfg Config, name string, logger log.Lo
1921
bucketConfig := gcs.Config{
2022
Bucket: cfg.BucketName,
2123
ServiceAccount: cfg.ServiceAccount.String(),
24+
HTTPConfig: exthttp.HTTPConfig{
25+
IdleConnTimeout: model.Duration(cfg.HTTP.IdleConnTimeout),
26+
ResponseHeaderTimeout: model.Duration(cfg.HTTP.ResponseHeaderTimeout),
27+
InsecureSkipVerify: cfg.HTTP.InsecureSkipVerify,
28+
TLSHandshakeTimeout: model.Duration(cfg.HTTP.TLSHandshakeTimeout),
29+
ExpectContinueTimeout: model.Duration(cfg.HTTP.ExpectContinueTimeout),
30+
MaxIdleConns: cfg.HTTP.MaxIdleConns,
31+
MaxIdleConnsPerHost: cfg.HTTP.MaxIdleConnsPerHost,
32+
MaxConnsPerHost: cfg.HTTP.MaxConnsPerHost,
33+
},
2234
}
2335

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

Diff for: pkg/objstore/providers/gcs/config.go

+26
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package gcs
77

88
import (
99
"flag"
10+
"time"
1011

1112
"github.com/grafana/dskit/flagext"
1213
)
@@ -15,6 +16,7 @@ import (
1516
type Config struct {
1617
BucketName string `yaml:"bucket_name"`
1718
ServiceAccount flagext.Secret `yaml:"service_account" doc:"description_method=GCSServiceAccountLongDescription"`
19+
HTTP HTTPConfig `yaml:"http"`
1820
}
1921

2022
// RegisterFlags registers the flags for GCS storage
@@ -26,6 +28,30 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
2628
func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
2729
f.StringVar(&cfg.BucketName, prefix+"gcs.bucket-name", "", "GCS bucket name")
2830
f.Var(&cfg.ServiceAccount, prefix+"gcs.service-account", cfg.GCSServiceAccountShortDescription())
31+
cfg.HTTP.RegisterFlagsWithPrefix(prefix, f)
32+
}
33+
34+
type HTTPConfig struct {
35+
IdleConnTimeout time.Duration `yaml:"idle_conn_timeout"`
36+
ResponseHeaderTimeout time.Duration `yaml:"response_header_timeout"`
37+
InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
38+
TLSHandshakeTimeout time.Duration `yaml:"tls_handshake_timeout"`
39+
ExpectContinueTimeout time.Duration `yaml:"expect_continue_timeout"`
40+
MaxIdleConns int `yaml:"max_idle_conns"`
41+
MaxIdleConnsPerHost int `yaml:"max_idle_conns_per_host"`
42+
MaxConnsPerHost int `yaml:"max_conns_per_host"`
43+
}
44+
45+
// RegisterFlagsWithPrefix registers the flags for s3 storage with the provided prefix
46+
func (cfg *HTTPConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
47+
f.DurationVar(&cfg.IdleConnTimeout, prefix+"gcs.http.idle-conn-timeout", 90*time.Second, "The time an idle connection will remain idle before closing.")
48+
f.DurationVar(&cfg.ResponseHeaderTimeout, prefix+"gcs.http.response-header-timeout", 2*time.Minute, "The amount of time the client will wait for a servers response headers.")
49+
f.BoolVar(&cfg.InsecureSkipVerify, prefix+"gcs.http.insecure-skip-verify", false, "If the client connects to GCS via HTTPS and this option is enabled, the client will accept any certificate and hostname.")
50+
f.DurationVar(&cfg.TLSHandshakeTimeout, prefix+"gcs.tls-handshake-timeout", 10*time.Second, "Maximum time to wait for a TLS handshake. 0 means no limit.")
51+
f.DurationVar(&cfg.ExpectContinueTimeout, prefix+"gcs.expect-continue-timeout", 1*time.Second, "The time to wait for a server's first response headers after fully writing the request headers if the request has an Expect header. 0 to send the request body immediately.")
52+
f.IntVar(&cfg.MaxIdleConns, prefix+"gcs.max-idle-connections", 0, "Maximum number of idle (keep-alive) connections across all hosts. 0 means no limit.")
53+
f.IntVar(&cfg.MaxIdleConnsPerHost, prefix+"gcs.max-idle-connections-per-host", 100, "Maximum number of idle (keep-alive) connections to keep per-host. If 0, a built-in default value is used.")
54+
f.IntVar(&cfg.MaxConnsPerHost, prefix+"gcs.max-connections-per-host", 0, "Maximum number of connections per host. 0 means no limit.")
2955
}
3056

3157
func (cfg *Config) GCSServiceAccountShortDescription() string {

Diff for: pkg/phlare/phlare.go

+4
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ func (c *Config) registerServerFlagsWithChangedDefaultValues(fs *flag.FlagSet) {
233233
"segment-writer.heartbeat-timeout": "1m",
234234
"segment-writer.unregister-on-shutdown": "false",
235235
"segment-writer.min-ready-duration": "30s",
236+
"storage.s3.http.idle-conn-timeout": "10m",
237+
"storage.s3.max-idle-connections-per-host": "1000",
238+
"storage.gcs.http.idle-conn-timeout": "10m",
239+
"storage.gcs.max-idle-connections-per-host": "1000",
236240
} {
237241
overrides[k] = v
238242
}

0 commit comments

Comments
 (0)