Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ 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 @@ -1625,11 +1624,14 @@ func (t *Loki) initMemberlistKV() (services.Service, error) {
)
dnsProvider := dns.NewProvider(util_log.Logger, dnsProviderReg, dns.GolangResolverType)

// TODO(ashwanth): This is not considering component specific overrides for InstanceInterfaceNames.
// This should be fixed in the future.
var err error
t.Cfg.MemberlistKV.AdvertiseAddr, err = GetInstanceAddr(
t.Cfg.MemberlistKV.AdvertiseAddr, err = ring.GetInstanceAddr(
t.Cfg.MemberlistKV.AdvertiseAddr,
t.Cfg.Common.InstanceInterfaceNames,
t.Cfg.Common.Ring.InstanceInterfaceNames,
util_log.Logger,
t.Cfg.Common.Ring.EnableIPv6,
)
if err != nil {
return nil, err
Expand Down Expand Up @@ -2373,11 +2375,3 @@ func schemaHasBoltDBShipperConfig(scfg config.SchemaConfig) bool {

return false
}

func GetInstanceAddr(addr string, netInterfaces []string, logger log.Logger) (string, error) {
if addr != "" {
return addr, nil
}

return netutil.GetFirstAddressOf(netInterfaces, logger, false)
}
4 changes: 2 additions & 2 deletions pkg/lokifrontend/frontend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"

"github.com/go-kit/log"
"github.com/grafana/dskit/netutil"
"github.com/grafana/dskit/ring"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
Expand All @@ -13,7 +14,6 @@ import (
v1 "github.com/grafana/loki/v3/pkg/lokifrontend/frontend/v1"
v2 "github.com/grafana/loki/v3/pkg/lokifrontend/frontend/v2"
"github.com/grafana/loki/v3/pkg/querier/queryrange/queryrangebase"
"github.com/grafana/loki/v3/pkg/util"
)

// This struct combines several configuration options together to preserve backwards compatibility.
Expand Down Expand Up @@ -48,7 +48,7 @@ func InitFrontend(cfg CombinedFrontendConfig, ring ring.ReadRing, limits v1.Limi
case cfg.FrontendV2.SchedulerAddress != "" || ring != nil:
// If query-scheduler address is configured, use Frontend.
if cfg.FrontendV2.Addr == "" {
addr, err := util.GetFirstAddressOf(cfg.FrontendV2.InfNames, log)
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/lokifrontend/frontend/v2/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ type Config struct {
GracefulShutdownTimeout time.Duration `yaml:"graceful_shutdown_timeout"`

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

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

cfg.InfNames = netutil.PrivateNetworkInterfacesWithFallback([]string{"eth0", "en0"}, util_log.Logger)
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.")
f.BoolVar(&cfg.EnableIPv6, "frontend.instance-enable-ipv6", false, "Enable using a IPv6 instance address (default false).")
f.StringVar(&cfg.Addr, "frontend.instance-addr", "", "IP address to advertise to querier (via scheduler) (resolved via interfaces by default).")
f.IntVar(&cfg.Port, "frontend.instance-port", 0, "Port to advertise to querier (via scheduler) (defaults to server.grpc-listen-port).")

Expand Down
Loading