From 7b99d91debb8bd60897e4d1a9faa2fe8bf12084f Mon Sep 17 00:00:00 2001 From: Martin Valiente Ainz <64830185+tinitiuset@users.noreply.github.com> Date: Thu, 6 Mar 2025 13:10:18 +0100 Subject: [PATCH] Upgrade DSKit (#10821) --- cmd/mimir/config-descriptor.json | 40 +++++++++---------- cmd/mimir/help-all.txt.tmpl | 20 +++++----- .../configuration-parameters/index.md | 7 ++-- go.mod | 2 +- go.sum | 4 +- .../grafana/dskit/cache/memcached_client.go | 29 +++++--------- .../grafana/dskit/flagext/secret.go | 5 +++ vendor/modules.txt | 2 +- 8 files changed, 53 insertions(+), 56 deletions(-) diff --git a/cmd/mimir/config-descriptor.json b/cmd/mimir/config-descriptor.json index fc827418211..f1f7582d577 100644 --- a/cmd/mimir/config-descriptor.json +++ b/cmd/mimir/config-descriptor.json @@ -6597,12 +6597,12 @@ }, { "kind": "field", - "name": "dns_initialization_enabled", + "name": "dns_ignore_startup_failures", "required": false, - "desc": "Enable initial DNS lookup and background resolution on memcached client creation.", + "desc": "Allow client creation even if initial DNS resolution fails.", "fieldValue": null, - "fieldDefaultValue": true, - "fieldFlag": "query-frontend.results-cache.memcached.dns-initialization-enabled", + "fieldDefaultValue": false, + "fieldFlag": "query-frontend.results-cache.memcached.dns-ignore-startup-failures", "fieldType": "boolean", "fieldCategory": "experimental" } @@ -8752,12 +8752,12 @@ }, { "kind": "field", - "name": "dns_initialization_enabled", + "name": "dns_ignore_startup_failures", "required": false, - "desc": "Enable initial DNS lookup and background resolution on memcached client creation.", + "desc": "Allow client creation even if initial DNS resolution fails.", "fieldValue": null, - "fieldDefaultValue": true, - "fieldFlag": "blocks-storage.bucket-store.index-cache.memcached.dns-initialization-enabled", + "fieldDefaultValue": false, + "fieldFlag": "blocks-storage.bucket-store.index-cache.memcached.dns-ignore-startup-failures", "fieldType": "boolean", "fieldCategory": "experimental" } @@ -9326,12 +9326,12 @@ }, { "kind": "field", - "name": "dns_initialization_enabled", + "name": "dns_ignore_startup_failures", "required": false, - "desc": "Enable initial DNS lookup and background resolution on memcached client creation.", + "desc": "Allow client creation even if initial DNS resolution fails.", "fieldValue": null, - "fieldDefaultValue": true, - "fieldFlag": "blocks-storage.bucket-store.chunks-cache.memcached.dns-initialization-enabled", + "fieldDefaultValue": false, + "fieldFlag": "blocks-storage.bucket-store.chunks-cache.memcached.dns-ignore-startup-failures", "fieldType": "boolean", "fieldCategory": "experimental" } @@ -9924,12 +9924,12 @@ }, { "kind": "field", - "name": "dns_initialization_enabled", + "name": "dns_ignore_startup_failures", "required": false, - "desc": "Enable initial DNS lookup and background resolution on memcached client creation.", + "desc": "Allow client creation even if initial DNS resolution fails.", "fieldValue": null, - "fieldDefaultValue": true, - "fieldFlag": "blocks-storage.bucket-store.metadata-cache.memcached.dns-initialization-enabled", + "fieldDefaultValue": false, + "fieldFlag": "blocks-storage.bucket-store.metadata-cache.memcached.dns-ignore-startup-failures", "fieldType": "boolean", "fieldCategory": "experimental" } @@ -15244,12 +15244,12 @@ }, { "kind": "field", - "name": "dns_initialization_enabled", + "name": "dns_ignore_startup_failures", "required": false, - "desc": "Enable initial DNS lookup and background resolution on memcached client creation.", + "desc": "Allow client creation even if initial DNS resolution fails.", "fieldValue": null, - "fieldDefaultValue": true, - "fieldFlag": "ruler-storage.cache.memcached.dns-initialization-enabled", + "fieldDefaultValue": false, + "fieldFlag": "ruler-storage.cache.memcached.dns-ignore-startup-failures", "fieldType": "boolean", "fieldCategory": "experimental" } diff --git a/cmd/mimir/help-all.txt.tmpl b/cmd/mimir/help-all.txt.tmpl index cef53de0a35..f1aa9b72737 100644 --- a/cmd/mimir/help-all.txt.tmpl +++ b/cmd/mimir/help-all.txt.tmpl @@ -439,8 +439,8 @@ Usage of ./cmd/mimir/mimir: Comma-separated list of memcached addresses. Each address can be an IP address, hostname, or an entry specified in the DNS Service Discovery format. -blocks-storage.bucket-store.chunks-cache.memcached.connect-timeout duration The connection timeout. (default 200ms) - -blocks-storage.bucket-store.chunks-cache.memcached.dns-initialization-enabled - [experimental] Enable initial DNS lookup and background resolution on memcached client creation. (default true) + -blocks-storage.bucket-store.chunks-cache.memcached.dns-ignore-startup-failures + [experimental] Allow client creation even if initial DNS resolution fails. -blocks-storage.bucket-store.chunks-cache.memcached.max-async-buffer-size int The maximum number of enqueued asynchronous operations allowed. (default 25000) -blocks-storage.bucket-store.chunks-cache.memcached.max-async-concurrency int @@ -545,8 +545,8 @@ Usage of ./cmd/mimir/mimir: Comma-separated list of memcached addresses. Each address can be an IP address, hostname, or an entry specified in the DNS Service Discovery format. -blocks-storage.bucket-store.index-cache.memcached.connect-timeout duration The connection timeout. (default 200ms) - -blocks-storage.bucket-store.index-cache.memcached.dns-initialization-enabled - [experimental] Enable initial DNS lookup and background resolution on memcached client creation. (default true) + -blocks-storage.bucket-store.index-cache.memcached.dns-ignore-startup-failures + [experimental] Allow client creation even if initial DNS resolution fails. -blocks-storage.bucket-store.index-cache.memcached.max-async-buffer-size int The maximum number of enqueued asynchronous operations allowed. (default 25000) -blocks-storage.bucket-store.index-cache.memcached.max-async-concurrency int @@ -669,8 +669,8 @@ Usage of ./cmd/mimir/mimir: Comma-separated list of memcached addresses. Each address can be an IP address, hostname, or an entry specified in the DNS Service Discovery format. -blocks-storage.bucket-store.metadata-cache.memcached.connect-timeout duration The connection timeout. (default 200ms) - -blocks-storage.bucket-store.metadata-cache.memcached.dns-initialization-enabled - [experimental] Enable initial DNS lookup and background resolution on memcached client creation. (default true) + -blocks-storage.bucket-store.metadata-cache.memcached.dns-ignore-startup-failures + [experimental] Allow client creation even if initial DNS resolution fails. -blocks-storage.bucket-store.metadata-cache.memcached.max-async-buffer-size int The maximum number of enqueued asynchronous operations allowed. (default 25000) -blocks-storage.bucket-store.metadata-cache.memcached.max-async-concurrency int @@ -2407,8 +2407,8 @@ Usage of ./cmd/mimir/mimir: Comma-separated list of memcached addresses. Each address can be an IP address, hostname, or an entry specified in the DNS Service Discovery format. -query-frontend.results-cache.memcached.connect-timeout duration The connection timeout. (default 200ms) - -query-frontend.results-cache.memcached.dns-initialization-enabled - [experimental] Enable initial DNS lookup and background resolution on memcached client creation. (default true) + -query-frontend.results-cache.memcached.dns-ignore-startup-failures + [experimental] Allow client creation even if initial DNS resolution fails. -query-frontend.results-cache.memcached.max-async-buffer-size int The maximum number of enqueued asynchronous operations allowed. (default 25000) -query-frontend.results-cache.memcached.max-async-concurrency int @@ -2675,8 +2675,8 @@ Usage of ./cmd/mimir/mimir: Comma-separated list of memcached addresses. Each address can be an IP address, hostname, or an entry specified in the DNS Service Discovery format. -ruler-storage.cache.memcached.connect-timeout duration The connection timeout. (default 200ms) - -ruler-storage.cache.memcached.dns-initialization-enabled - [experimental] Enable initial DNS lookup and background resolution on memcached client creation. (default true) + -ruler-storage.cache.memcached.dns-ignore-startup-failures + [experimental] Allow client creation even if initial DNS resolution fails. -ruler-storage.cache.memcached.max-async-buffer-size int The maximum number of enqueued asynchronous operations allowed. (default 25000) -ruler-storage.cache.memcached.max-async-concurrency int diff --git a/docs/sources/mimir/configure/configuration-parameters/index.md b/docs/sources/mimir/configure/configuration-parameters/index.md index 634f64b715f..43222c07f8e 100644 --- a/docs/sources/mimir/configure/configuration-parameters/index.md +++ b/docs/sources/mimir/configure/configuration-parameters/index.md @@ -5271,10 +5271,9 @@ The `memcached` block configures the Memcached-based caching backend. The suppor # CLI flag: -.memcached.tls-min-version [tls_min_version: | default = ""] -# (experimental) Enable initial DNS lookup and background resolution on -# memcached client creation. -# CLI flag: -.memcached.dns-initialization-enabled -[dns_initialization_enabled: | default = true] +# (experimental) Allow client creation even if initial DNS resolution fails. +# CLI flag: -.memcached.dns-ignore-startup-failures +[dns_ignore_startup_failures: | default = false] ``` ### redis diff --git a/go.mod b/go.mod index 472ee1f9920..06cf83915ec 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/golang/snappy v0.0.4 github.com/google/gopacket v1.1.19 github.com/gorilla/mux v1.8.1 - github.com/grafana/dskit v0.0.0-20250303172748-fd4441b85237 + github.com/grafana/dskit v0.0.0-20250306085730-ce8a4c05c652 github.com/grafana/e2e v0.1.2-0.20250306030804-b80b212be908 github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/influxdata/influxdb/v2 v2.7.11 diff --git a/go.sum b/go.sum index e6d48567625..3608c1f35c7 100644 --- a/go.sum +++ b/go.sum @@ -1272,8 +1272,8 @@ github.com/grafana-tools/sdk v0.0.0-20220919052116-6562121319fc h1:PXZQA2WCxe85T github.com/grafana-tools/sdk v0.0.0-20220919052116-6562121319fc/go.mod h1:AHHlOEv1+GGQ3ktHMlhuTUwo3zljV3QJbC0+8o2kn+4= github.com/grafana/alerting v0.0.0-20250225150117-15e285d78df2 h1:kESrzm0FcRVLmGIQCgl1MCwDGLH4sLzWphr7mcFdbfI= github.com/grafana/alerting v0.0.0-20250225150117-15e285d78df2/go.mod h1:hdGB3dSl8Ma9Rjo2YiAEAjMkZ5HiNJbNDqRKDefRZrM= -github.com/grafana/dskit v0.0.0-20250303172748-fd4441b85237 h1:VZagYtPcmjgazfPAuWN7lER6mprG20r51+1eYPpATkw= -github.com/grafana/dskit v0.0.0-20250303172748-fd4441b85237/go.mod h1:cu2zIOHhAgRaIDuECsERftSp1l7KHq1aX1jgihQCu0c= +github.com/grafana/dskit v0.0.0-20250306085730-ce8a4c05c652 h1:2qPaT8hBXloPWB1CtYYpgGeEESsAh+VoBGgL1UpbOUc= +github.com/grafana/dskit v0.0.0-20250306085730-ce8a4c05c652/go.mod h1:cu2zIOHhAgRaIDuECsERftSp1l7KHq1aX1jgihQCu0c= github.com/grafana/e2e v0.1.2-0.20250306030804-b80b212be908 h1:l3pFNUs4heAhiXnMo0thaJQrNWeE4SgLqUOEUmZtC6A= github.com/grafana/e2e v0.1.2-0.20250306030804-b80b212be908/go.mod h1:JVmqPBe8A/pZWwRoJW5ZjyALeY5OXMzPl7LrVXOdZAI= github.com/grafana/franz-go v0.0.0-20241009100846-782ba1442937 h1:fwwnG/NcygoS6XbAaEyK2QzMXI/BZIEJvQ3CD+7XZm8= diff --git a/vendor/github.com/grafana/dskit/cache/memcached_client.go b/vendor/github.com/grafana/dskit/cache/memcached_client.go index 57245235e25..ff92e1013bb 100644 --- a/vendor/github.com/grafana/dskit/cache/memcached_client.go +++ b/vendor/github.com/grafana/dskit/cache/memcached_client.go @@ -125,9 +125,9 @@ type MemcachedClientConfig struct { // TLS to use to connect to the Memcached server. TLS dstls.ClientConfig `yaml:",inline"` - // DNSInitializationEnabled enables initial DNS lookup and background resolution on client creation. - // When false, Initialize() must be called manually. - DNSInitializationEnabled bool `yaml:"dns_initialization_enabled" category:"experimental"` + // DNSIgnoreStartupFailures allows the client to start even if initial DNS resolution fails. + // When true, DNS failures are logged but client creation succeeds. + DNSIgnoreStartupFailures bool `yaml:"dns_ignore_startup_failures" category:"experimental"` } func (c *MemcachedClientConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { @@ -145,7 +145,7 @@ func (c *MemcachedClientConfig) RegisterFlagsWithPrefix(prefix string, f *flag.F f.IntVar(&c.MaxItemSize, prefix+"max-item-size", 1024*1024, "The maximum size of an item stored in memcached, in bytes. Bigger items are not stored. If set to 0, no maximum size is enforced.") f.BoolVar(&c.TLSEnabled, prefix+"tls-enabled", false, "Enable connecting to Memcached with TLS.") c.TLS.RegisterFlagsWithPrefix(prefix, f) - f.BoolVar(&c.DNSInitializationEnabled, prefix+"dns-initialization-enabled", true, "Enable initial DNS lookup and background resolution on memcached client creation.") + f.BoolVar(&c.DNSIgnoreStartupFailures, prefix+"dns-ignore-startup-failures", false, "Allow client creation even if initial DNS resolution fails.") } func (c *MemcachedClientConfig) Validate() error { @@ -245,10 +245,13 @@ func NewMemcachedClientWithConfig(logger log.Logger, name string, config Memcach return nil, err } - if config.DNSInitializationEnabled { - if err := mcClient.Initialize(); err != nil { - return nil, err - } + // Start the background DNS resolution + go mcClient.resolveAddrsLoop() + + // Do initial DNS resolution + if err := mcClient.resolveAddrs(); err != nil && !config.DNSIgnoreStartupFailures { + mcClient.Stop() + return nil, err } return mcClient, nil @@ -310,16 +313,6 @@ func newMemcachedClient( return c, nil } -// Initialize will start the background DNS resolution periodically and do an initial DNS resolution. -// The background resolution goroutine is started even if the initial resolution fails. -func (c *MemcachedClient) Initialize() error { - // Start the background DNS resolution - go c.resolveAddrsLoop() - - // Do initial DNS resolution - return c.resolveAddrs() -} - func (c *MemcachedClient) Stop() { close(c.stop) diff --git a/vendor/github.com/grafana/dskit/flagext/secret.go b/vendor/github.com/grafana/dskit/flagext/secret.go index d6c1a443245..80a3e87972d 100644 --- a/vendor/github.com/grafana/dskit/flagext/secret.go +++ b/vendor/github.com/grafana/dskit/flagext/secret.go @@ -37,3 +37,8 @@ func (v Secret) MarshalYAML() (interface{}, error) { } return "********", nil } + +// Equal implements go-cmp equality. +func (v Secret) Equal(other Secret) bool { + return v.value == other.value +} diff --git a/vendor/modules.txt b/vendor/modules.txt index d6db167b3e8..e337cb45f4f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -649,7 +649,7 @@ github.com/grafana/alerting/receivers/webex github.com/grafana/alerting/receivers/webhook github.com/grafana/alerting/receivers/wecom github.com/grafana/alerting/templates -# github.com/grafana/dskit v0.0.0-20250303172748-fd4441b85237 +# github.com/grafana/dskit v0.0.0-20250306085730-ce8a4c05c652 ## explicit; go 1.21 github.com/grafana/dskit/backoff github.com/grafana/dskit/ballast