Skip to content

Commit

Permalink
Reapply "fix(memberlist): Respect interface names config for advertis…
Browse files Browse the repository at this point in the history
…e address (#13940)"

This reverts commit 523f991.
  • Loading branch information
trevorwhitney committed Dec 9, 2024
1 parent 79101b3 commit 130ae9e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,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 @@ -1386,6 +1387,15 @@ func (t *Loki) initMemberlistKV() (services.Service, error) {
)
dnsProvider := dns.NewProvider(util_log.Logger, dnsProviderReg, dns.GolangResolverType)

var err error
t.Cfg.MemberlistKV.AdvertiseAddr, err = GetInstanceAddr(
t.Cfg.MemberlistKV.AdvertiseAddr,
t.Cfg.Common.InstanceInterfaceNames,
util_log.Logger,
)
if err != nil {
return nil, err
}
t.MemberlistKV = memberlist.NewKVInitService(&t.Cfg.MemberlistKV, util_log.Logger, dnsProvider, reg)

t.Cfg.CompactorConfig.CompactorRing.KVStore.MemberlistKV = t.MemberlistKV.GetMemberlistKV
Expand Down Expand Up @@ -2018,3 +2028,11 @@ 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)
}

0 comments on commit 130ae9e

Please sign in to comment.