Skip to content

Commit aed4610

Browse files
fix(frontend): allow resolution of v6 addresses. (backport release-3.5.x) (#18261)
Co-authored-by: Ashwanth <iamashwanth@gmail.com>
1 parent 6f878ad commit aed4610

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

‎docs/sources/shared/configuration.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,6 +2713,10 @@ The `frontend` block configures the Loki query-frontend.
27132713
# CLI flag: -frontend.instance-interface-names
27142714
[instance_interface_names: <list of strings> | default = [<private network interfaces>]]
27152715
2716+
# Enable using a IPv6 instance address (default false).
2717+
# CLI flag: -frontend.instance-enable-ipv6
2718+
[instance_enable_ipv6: <boolean> | default = false]
2719+
27162720
# Defines the encoding for requests to and responses from the scheduler and
27172721
# querier. Can be 'json' or 'protobuf' (defaults to 'json').
27182722
# CLI flag: -frontend.encoding

‎pkg/lokifrontend/frontend/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"net/http"
66

77
"github.com/go-kit/log"
8+
"github.com/grafana/dskit/netutil"
89
"github.com/grafana/dskit/ring"
910
"github.com/pkg/errors"
1011
"github.com/prometheus/client_golang/prometheus"
@@ -13,7 +14,6 @@ import (
1314
v1 "github.com/grafana/loki/v3/pkg/lokifrontend/frontend/v1"
1415
v2 "github.com/grafana/loki/v3/pkg/lokifrontend/frontend/v2"
1516
"github.com/grafana/loki/v3/pkg/querier/queryrange/queryrangebase"
16-
"github.com/grafana/loki/v3/pkg/util"
1717
)
1818

1919
// This struct combines several configuration options together to preserve backwards compatibility.
@@ -48,7 +48,7 @@ func InitFrontend(cfg CombinedFrontendConfig, ring ring.ReadRing, limits v1.Limi
4848
case cfg.FrontendV2.SchedulerAddress != "" || ring != nil:
4949
// If query-scheduler address is configured, use Frontend.
5050
if cfg.FrontendV2.Addr == "" {
51-
addr, err := util.GetFirstAddressOf(cfg.FrontendV2.InfNames, log)
51+
addr, err := netutil.GetFirstAddressOf(cfg.FrontendV2.InfNames, log, cfg.FrontendV2.EnableIPv6)
5252
if err != nil {
5353
return nil, nil, nil, errors.Wrap(err, "failed to get frontend address")
5454
}

‎pkg/lokifrontend/frontend/v2/frontend.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ type Config struct {
5151
GracefulShutdownTimeout time.Duration `yaml:"graceful_shutdown_timeout"`
5252

5353
// Used to find local IP address, that is sent to scheduler and querier-worker.
54-
InfNames []string `yaml:"instance_interface_names" doc:"default=[<private network interfaces>]"`
54+
InfNames []string `yaml:"instance_interface_names" doc:"default=[<private network interfaces>]"`
55+
EnableIPv6 bool `yaml:"instance_enable_ipv6"`
5556

5657
// If set, address is not computed from interfaces.
5758
Addr string `yaml:"address" doc:"hidden"`
@@ -69,6 +70,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
6970

7071
cfg.InfNames = netutil.PrivateNetworkInterfacesWithFallback([]string{"eth0", "en0"}, util_log.Logger)
7172
f.Var((*flagext.StringSlice)(&cfg.InfNames), "frontend.instance-interface-names", "Name of network interface to read address from. This address is sent to query-scheduler and querier, which uses it to send the query response back to query-frontend.")
73+
f.BoolVar(&cfg.EnableIPv6, "frontend.instance-enable-ipv6", false, "Enable using a IPv6 instance address (default false).")
7274
f.StringVar(&cfg.Addr, "frontend.instance-addr", "", "IP address to advertise to querier (via scheduler) (resolved via interfaces by default).")
7375
f.IntVar(&cfg.Port, "frontend.instance-port", 0, "Port to advertise to querier (via scheduler) (defaults to server.grpc-listen-port).")
7476

0 commit comments

Comments
 (0)