Skip to content

Commit

Permalink
Frontend ipv6 support (#6173)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke-Smartnews authored Oct 12, 2023
1 parent 2bcab7f commit 40b787d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions cmd/mimir/config-descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions cmd/mimir/help-all.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 [<private network interfaces>])
-query-frontend.instance-port int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,10 @@ The `frontend` block configures the query-frontend.
# CLI flag: -query-frontend.instance-interface-names
[instance_interface_names: <list of strings> | default = [<private network interfaces>]]
# (advanced) Enable using a IPv6 instance address (default false).
# CLI flag: -query-frontend.instance-enable-ipv6
[instance_enable_ipv6: <boolean> | 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
Expand Down
4 changes: 2 additions & 2 deletions pkg/frontend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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.
Expand Down Expand Up @@ -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")
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/frontend/v2/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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=[<private network interfaces>]"`
InfNames []string `yaml:"instance_interface_names" category:"advanced" doc:"default=[<private network interfaces>]"`
EnableIPv6 bool `yaml:"instance_enable_ipv6" category:"advanced"`

// If set, address is not computed from interfaces.
Addr string `yaml:"address" category:"advanced"`
Expand All @@ -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).")
Expand Down

0 comments on commit 40b787d

Please sign in to comment.