From 40b787d8317f3d1774a998442e57c6ea6543e368 Mon Sep 17 00:00:00 2001 From: Luke <93500761+Luke-Smartnews@users.noreply.github.com> Date: Thu, 12 Oct 2023 11:52:55 +0900 Subject: [PATCH] Frontend ipv6 support (#6173) --- CHANGELOG.md | 1 + cmd/mimir/config-descriptor.json | 11 +++++++++++ cmd/mimir/help-all.txt.tmpl | 2 ++ .../references/configuration-parameters/index.md | 4 ++++ pkg/frontend/config.go | 4 ++-- pkg/frontend/v2/frontend.go | 4 +++- 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 911e6ae73e6..0763b42facc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ * [ENHANCEMENT] All: added an experimental `-server.grpc.num-workers` flag that configures the number of long-living workers used to process gRPC requests. This could decrease the CPU usage by reducing the number of stack allocations. #6311 * [ENHANCEMENT] All: improved IPv6 support by using the proper host:port formatting. #6311 * [ENHANCEMENT] Querier: always return error encountered during chunks streaming, rather than `the stream has already been exhausted`. #6345 +* [ENHANCEMENT] Query-frontend: add `instance_enable_ipv6` to support IPv6. #6111 * [BUGFIX] Ring: Ensure network addresses used for component hash rings are formatted correctly when using IPv6. #6068 * [BUGFIX] Query-scheduler: don't retain connections from queriers that have shut down, leading to gradually increasing enqueue latency over time. #6100 #6145 * [BUGFIX] Ingester: prevent query logic from continuing to execute after queries are canceled. #6085 diff --git a/cmd/mimir/config-descriptor.json b/cmd/mimir/config-descriptor.json index 7b1697839c2..72faa56ebbe 100644 --- a/cmd/mimir/config-descriptor.json +++ b/cmd/mimir/config-descriptor.json @@ -4517,6 +4517,17 @@ "fieldType": "list of strings", "fieldCategory": "advanced" }, + { + "kind": "field", + "name": "instance_enable_ipv6", + "required": false, + "desc": "Enable using a IPv6 instance address (default false).", + "fieldValue": null, + "fieldDefaultValue": false, + "fieldFlag": "query-frontend.instance-enable-ipv6", + "fieldType": "boolean", + "fieldCategory": "advanced" + }, { "kind": "field", "name": "address", diff --git a/cmd/mimir/help-all.txt.tmpl b/cmd/mimir/help-all.txt.tmpl index f416a2ad20f..cd696c56e14 100644 --- a/cmd/mimir/help-all.txt.tmpl +++ b/cmd/mimir/help-all.txt.tmpl @@ -1751,6 +1751,8 @@ Usage of ./cmd/mimir/mimir: Override the expected name on the server certificate. -query-frontend.instance-addr string IP address to advertise to the querier (via scheduler) (default is auto-detected from network interfaces). + -query-frontend.instance-enable-ipv6 + Enable using a IPv6 instance address (default false). -query-frontend.instance-interface-names string List of network interface names to look up when finding the instance IP address. This address is sent to query-scheduler and querier, which uses it to send the query response back to query-frontend. (default []) -query-frontend.instance-port int diff --git a/docs/sources/mimir/references/configuration-parameters/index.md b/docs/sources/mimir/references/configuration-parameters/index.md index e8dd13baaab..c79dda8f5dd 100644 --- a/docs/sources/mimir/references/configuration-parameters/index.md +++ b/docs/sources/mimir/references/configuration-parameters/index.md @@ -1349,6 +1349,10 @@ The `frontend` block configures the query-frontend. # CLI flag: -query-frontend.instance-interface-names [instance_interface_names: | default = []] +# (advanced) Enable using a IPv6 instance address (default false). +# CLI flag: -query-frontend.instance-enable-ipv6 +[instance_enable_ipv6: | default = false] + # (advanced) IP address to advertise to the querier (via scheduler) (default is # auto-detected from network interfaces). # CLI flag: -query-frontend.instance-addr diff --git a/pkg/frontend/config.go b/pkg/frontend/config.go index d3b8babd4ee..e3ba7751606 100644 --- a/pkg/frontend/config.go +++ b/pkg/frontend/config.go @@ -10,6 +10,7 @@ import ( "net/http" "github.com/go-kit/log" + "github.com/grafana/dskit/netutil" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -18,7 +19,6 @@ import ( v1 "github.com/grafana/mimir/pkg/frontend/v1" v2 "github.com/grafana/mimir/pkg/frontend/v2" "github.com/grafana/mimir/pkg/scheduler/schedulerdiscovery" - "github.com/grafana/mimir/pkg/util" ) // CombinedFrontendConfig combines several configuration options together to preserve backwards compatibility. @@ -67,7 +67,7 @@ func InitFrontend(cfg CombinedFrontendConfig, limits v1.Limits, grpcListenPort i case cfg.FrontendV2.SchedulerAddress != "" || cfg.FrontendV2.QuerySchedulerDiscovery.Mode == schedulerdiscovery.ModeRing: // Query-scheduler is enabled when its address is configured or ring-based service discovery is configured. if cfg.FrontendV2.Addr == "" { - addr, err := util.GetFirstAddressOf(cfg.FrontendV2.InfNames) + addr, err := netutil.GetFirstAddressOf(cfg.FrontendV2.InfNames, log, cfg.FrontendV2.EnableIPv6) if err != nil { return nil, nil, nil, errors.Wrap(err, "failed to get frontend address") } diff --git a/pkg/frontend/v2/frontend.go b/pkg/frontend/v2/frontend.go index f3fd6f5a85a..fc8fbb12446 100644 --- a/pkg/frontend/v2/frontend.go +++ b/pkg/frontend/v2/frontend.go @@ -45,7 +45,8 @@ type Config struct { GRPCClientConfig grpcclient.Config `yaml:"grpc_client_config" doc:"description=Configures the gRPC client used to communicate between the query-frontends and the query-schedulers."` // Used to find local IP address, that is sent to scheduler and querier-worker. - InfNames []string `yaml:"instance_interface_names" category:"advanced" doc:"default=[]"` + InfNames []string `yaml:"instance_interface_names" category:"advanced" doc:"default=[]"` + EnableIPv6 bool `yaml:"instance_enable_ipv6" category:"advanced"` // If set, address is not computed from interfaces. Addr string `yaml:"address" category:"advanced"` @@ -61,6 +62,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet, logger log.Logger) { f.IntVar(&cfg.WorkerConcurrency, "query-frontend.scheduler-worker-concurrency", 5, "Number of concurrent workers forwarding queries to single query-scheduler.") cfg.InfNames = netutil.PrivateNetworkInterfacesWithFallback([]string{"eth0", "en0"}, logger) + f.BoolVar(&cfg.EnableIPv6, "query-frontend.instance-enable-ipv6", false, "Enable using a IPv6 instance address (default false).") f.Var((*flagext.StringSlice)(&cfg.InfNames), "query-frontend.instance-interface-names", "List of network interface names to look up when finding the instance IP address. This address is sent to query-scheduler and querier, which uses it to send the query response back to query-frontend.") f.StringVar(&cfg.Addr, "query-frontend.instance-addr", "", "IP address to advertise to the querier (via scheduler) (default is auto-detected from network interfaces).") f.IntVar(&cfg.Port, "query-frontend.instance-port", 0, "Port to advertise to querier (via scheduler) (defaults to server.grpc-listen-port).")