Skip to content

Commit

Permalink
fix: enable-ipv6 option is ignored (#3731)
Browse files Browse the repository at this point in the history
  • Loading branch information
kolesnikovae authored Dec 6, 2024
1 parent 0b668ad commit 749fbab
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 84 deletions.
4 changes: 4 additions & 0 deletions cmd/pyroscope/help-all.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,12 @@ Usage of ./pyroscope:
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
Port to advertise to query-scheduler and querier (defaults to -server.http-listen-port).
-query-frontend.scheduler-worker-concurrency int
Number of concurrent workers forwarding queries to single query-scheduler. (default 5)
-query-scheduler.grpc-client-config.backoff-max-period duration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,183 @@ pool_config:
# Timeout for ingester client healthcheck RPCs.
# CLI flag: -distributor.health-check-timeout
[remote_timeout: <duration> | default = 5s]
ring:
# The key-value store used to share the hash ring across multiple instances.
kvstore:
# Backend storage to use for the ring. Supported values are: consul, etcd,
# inmemory, memberlist, multi.
# CLI flag: -distributor.ring.store
[store: <string> | default = "memberlist"]
# The prefix for the keys in the store. Should end with a /.
# CLI flag: -distributor.ring.prefix
[prefix: <string> | default = "collectors/"]
consul:
# Hostname and port of Consul.
# CLI flag: -distributor.ring.consul.hostname
[host: <string> | default = "localhost:8500"]
# ACL Token used to interact with Consul.
# CLI flag: -distributor.ring.consul.acl-token
[acl_token: <string> | default = ""]
# HTTP timeout when talking to Consul
# CLI flag: -distributor.ring.consul.client-timeout
[http_client_timeout: <duration> | default = 20s]
# Enable consistent reads to Consul.
# CLI flag: -distributor.ring.consul.consistent-reads
[consistent_reads: <boolean> | default = false]
# Rate limit when watching key or prefix in Consul, in requests per
# second. 0 disables the rate limit.
# CLI flag: -distributor.ring.consul.watch-rate-limit
[watch_rate_limit: <float> | default = 1]
# Burst size used in rate limit. Values less than 1 are treated as 1.
# CLI flag: -distributor.ring.consul.watch-burst-size
[watch_burst_size: <int> | default = 1]
# Maximum duration to wait before retrying a Compare And Swap (CAS)
# operation.
# CLI flag: -distributor.ring.consul.cas-retry-delay
[cas_retry_delay: <duration> | default = 1s]
etcd:
# The etcd endpoints to connect to.
# CLI flag: -distributor.ring.etcd.endpoints
[endpoints: <list of strings> | default = []]
# The dial timeout for the etcd connection.
# CLI flag: -distributor.ring.etcd.dial-timeout
[dial_timeout: <duration> | default = 10s]
# The maximum number of retries to do for failed ops.
# CLI flag: -distributor.ring.etcd.max-retries
[max_retries: <int> | default = 10]
# Enable TLS.
# CLI flag: -distributor.ring.etcd.tls-enabled
[tls_enabled: <boolean> | default = false]
# Path to the client certificate, which will be used for authenticating
# with the server. Also requires the key path to be configured.
# CLI flag: -distributor.ring.etcd.tls-cert-path
[tls_cert_path: <string> | default = ""]
# Path to the key for the client certificate. Also requires the client
# certificate to be configured.
# CLI flag: -distributor.ring.etcd.tls-key-path
[tls_key_path: <string> | default = ""]
# Path to the CA certificates to validate server certificate against. If
# not set, the host's root CA certificates are used.
# CLI flag: -distributor.ring.etcd.tls-ca-path
[tls_ca_path: <string> | default = ""]
# Override the expected name on the server certificate.
# CLI flag: -distributor.ring.etcd.tls-server-name
[tls_server_name: <string> | default = ""]
# Skip validating server certificate.
# CLI flag: -distributor.ring.etcd.tls-insecure-skip-verify
[tls_insecure_skip_verify: <boolean> | default = false]
# Override the default cipher suite list (separated by commas). Allowed
# values:
#
# Secure Ciphers:
# - TLS_AES_128_GCM_SHA256
# - TLS_AES_256_GCM_SHA384
# - TLS_CHACHA20_POLY1305_SHA256
# - TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
# - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
# - TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
# - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
# - TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
# - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
# - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
# - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
# - TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
# - TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
#
# Insecure Ciphers:
# - TLS_RSA_WITH_RC4_128_SHA
# - TLS_RSA_WITH_3DES_EDE_CBC_SHA
# - TLS_RSA_WITH_AES_128_CBC_SHA
# - TLS_RSA_WITH_AES_256_CBC_SHA
# - TLS_RSA_WITH_AES_128_CBC_SHA256
# - TLS_RSA_WITH_AES_128_GCM_SHA256
# - TLS_RSA_WITH_AES_256_GCM_SHA384
# - TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
# - TLS_ECDHE_RSA_WITH_RC4_128_SHA
# - TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
# - TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
# - TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
# CLI flag: -distributor.ring.etcd.tls-cipher-suites
[tls_cipher_suites: <string> | default = ""]
# Override the default minimum TLS version. Allowed values: VersionTLS10,
# VersionTLS11, VersionTLS12, VersionTLS13
# CLI flag: -distributor.ring.etcd.tls-min-version
[tls_min_version: <string> | default = ""]
# Etcd username.
# CLI flag: -distributor.ring.etcd.username
[username: <string> | default = ""]
# Etcd password.
# CLI flag: -distributor.ring.etcd.password
[password: <string> | default = ""]
multi:
# Primary backend storage used by multi-client.
# CLI flag: -distributor.ring.multi.primary
[primary: <string> | default = ""]
# Secondary backend storage used by multi-client.
# CLI flag: -distributor.ring.multi.secondary
[secondary: <string> | default = ""]
# Mirror writes to secondary store.
# CLI flag: -distributor.ring.multi.mirror-enabled
[mirror_enabled: <boolean> | default = false]
# Timeout for storing value to secondary store.
# CLI flag: -distributor.ring.multi.mirror-timeout
[mirror_timeout: <duration> | default = 2s]
# Period at which to heartbeat to the ring. 0 = disabled.
# CLI flag: -distributor.ring.heartbeat-period
[heartbeat_period: <duration> | default = 15s]
# The heartbeat timeout after which distributors are considered unhealthy
# within the ring. 0 = never (timeout disabled).
# CLI flag: -distributor.ring.heartbeat-timeout
[heartbeat_timeout: <duration> | default = 1m]
# Instance ID to register in the ring.
# CLI flag: -distributor.ring.instance-id
[instance_id: <string> | default = "<hostname>"]
# List of network interface names to look up when finding the instance IP
# address.
# CLI flag: -distributor.ring.instance-interface-names
[instance_interface_names: <list of strings> | default = [<private network interfaces>]]
# Port to advertise in the ring (defaults to -server.http-listen-port).
# CLI flag: -distributor.ring.instance-port
[instance_port: <int> | default = 0]
# IP address to advertise in the ring. Default is auto-detected.
# CLI flag: -distributor.ring.instance-addr
[instance_addr: <string> | default = ""]
# Enable using a IPv6 instance address. (default false)
# CLI flag: -distributor.ring.instance-enable-ipv6
[instance_enable_ipv6: <boolean> | default = false]
```

### ingester
Expand Down Expand Up @@ -846,7 +1023,16 @@ The `query_frontend` block configures the query-frontend.
# IP address to advertise to the querier (via scheduler) (default is
# auto-detected from network interfaces).
# CLI flag: -query-frontend.instance-addr
[address: <string> | default = ""]
[instance_addr: <string> | default = ""]
# Enable using a IPv6 instance address. (default false)
# CLI flag: -query-frontend.instance-enable-ipv6
[instance_enable_ipv6: <boolean> | default = false]
# Port to advertise to query-scheduler and querier (defaults to
# -server.http-listen-port).
# CLI flag: -query-frontend.instance-port
[instance_port: <int> | default = 0]
```

### frontend_worker
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func New(cfg util.CommonRingConfig, logger log.Logger, reg prometheus.Registerer
return nil, errors.Wrap(err, "failed to initialize versions' KV store")
}

instanceAddr, err := ring.GetInstanceAddr(cfg.InstanceAddr, cfg.InstanceInterfaceNames, logger, false)
instanceAddr, err := ring.GetInstanceAddr(cfg.InstanceAddr, cfg.InstanceInterfaceNames, logger, cfg.EnableIPv6)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type Config struct {
PoolConfig clientpool.PoolConfig `yaml:"pool_config,omitempty"`

// Distributors ring
DistributorRing util.CommonRingConfig `yaml:"ring" doc:"hidden"`
DistributorRing util.CommonRingConfig `yaml:"ring"`
}

// RegisterFlags registers distributor-related flags.
Expand Down
2 changes: 1 addition & 1 deletion pkg/distributor/distributor_ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
)

func toBasicLifecyclerConfig(cfg util.CommonRingConfig, logger log.Logger) (ring.BasicLifecyclerConfig, error) {
instanceAddr, err := ring.GetInstanceAddr(cfg.InstanceAddr, cfg.InstanceInterfaceNames, logger, false)
instanceAddr, err := ring.GetInstanceAddr(cfg.InstanceAddr, cfg.InstanceInterfaceNames, logger, cfg.EnableIPv6)
if err != nil {
return ring.BasicLifecyclerConfig{}, err
}
Expand Down
15 changes: 10 additions & 5 deletions pkg/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ 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>]"`
Addr string `yaml:"instance_addr" category:"advanced"`
EnableIPv6 bool `yaml:"instance_enable_ipv6" category:"advanced"`
Port int `yaml:"instance_port" category:"advanced"`

// If set, address is not computed from interfaces.
Addr string `yaml:"address" category:"advanced"`
Port int `yaml:"-"`
// For backward compatibility only. The parameter has a name that is
// inconsistent with the way address is specified in other places.
// The parameter is replaced with `instance_addr`.
AddrOld string `yaml:"address" category:"advanced" doc:"hidden"`

// This configuration is injected internally.
QuerySchedulerDiscovery schedulerdiscovery.Config `yaml:"-"`
Expand All @@ -65,7 +69,8 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet, logger log.Logger) {
cfg.InfNames = netutil.PrivateNetworkInterfacesWithFallback([]string{"eth0", "en0"}, logger)
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.BoolVar(&cfg.EnableIPv6, "query-frontend.instance-enable-ipv6", false, "Enable using a IPv6 instance address. (default false)")
f.IntVar(&cfg.Port, "query-frontend.instance-port", 0, "Port to advertise to query-scheduler and querier (defaults to -server.http-listen-port).")
cfg.GRPCClientConfig.RegisterFlagsWithPrefix("query-frontend.grpc-client-config", f)
}

Expand Down
23 changes: 15 additions & 8 deletions pkg/phlare/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/grafana/dskit/kv/codec"
"github.com/grafana/dskit/kv/memberlist"
"github.com/grafana/dskit/middleware"
"github.com/grafana/dskit/netutil"
"github.com/grafana/dskit/ring"
"github.com/grafana/dskit/runtimeconfig"
"github.com/grafana/dskit/server"
Expand Down Expand Up @@ -107,15 +108,10 @@ const (
var objectStoreTypeStats = usagestats.NewString("store_object_type")

func (f *Phlare) initQueryFrontend() (services.Service, error) {
if f.Cfg.Frontend.Addr == "" {
addr, err := util.GetFirstAddressOf(f.Cfg.Frontend.InfNames)
if err != nil {
return nil, errors.Wrap(err, "failed to get frontend address")
}

f.Cfg.Frontend.Addr = addr
var err error
if f.Cfg.Frontend.Addr, err = f.getFrontendAddress(); err != nil {
return nil, fmt.Errorf("failed to get frontend address: %w", err)
}

if f.Cfg.Frontend.Port == 0 {
f.Cfg.Frontend.Port = f.Cfg.Server.HTTPListenPort
}
Expand All @@ -137,6 +133,17 @@ func (f *Phlare) initQueryFrontend() (services.Service, error) {
return frontendSvc, nil
}

func (f *Phlare) getFrontendAddress() (addr string, err error) {
addr = f.Cfg.Frontend.Addr
if f.Cfg.Frontend.AddrOld != "" {
addr = f.Cfg.Frontend.AddrOld
}
if addr != "" {
return addr, nil
}
return netutil.GetFirstAddressOf(f.Cfg.Frontend.InfNames, f.logger, f.Cfg.Frontend.EnableIPv6)
}

func (f *Phlare) initReadPathRouter() {
vcsService := vcs.New(
log.With(f.logger, "component", "vcs-service"),
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/schedulerdiscovery/ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (

// toBasicLifecyclerConfig returns a ring.BasicLifecyclerConfig based on the query-scheduler ring config.
func toBasicLifecyclerConfig(cfg util.CommonRingConfig, logger log.Logger) (ring.BasicLifecyclerConfig, error) {
instanceAddr, err := ring.GetInstanceAddr(cfg.InstanceAddr, cfg.InstanceInterfaceNames, logger, false)
instanceAddr, err := ring.GetInstanceAddr(cfg.InstanceAddr, cfg.InstanceInterfaceNames, logger, cfg.EnableIPv6)
if err != nil {
return ring.BasicLifecyclerConfig{}, err
}
Expand Down
65 changes: 0 additions & 65 deletions pkg/util/net.go

This file was deleted.

Loading

0 comments on commit 749fbab

Please sign in to comment.