Skip to content

Commit 751324c

Browse files
clwluvwchaudum
andauthored
fix(memberlist): Respect interface names config for advertise address (#13940)
Signed-off-by: Seena Fallah <seenafallah@gmail.com> Co-authored-by: Christian Haudum <christian.haudum@gmail.com>
1 parent 9922814 commit 751324c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎pkg/loki/modules.go

+18
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/grafana/dskit/kv/codec"
2424
"github.com/grafana/dskit/kv/memberlist"
2525
"github.com/grafana/dskit/middleware"
26+
"github.com/grafana/dskit/netutil"
2627
"github.com/grafana/dskit/ring"
2728
"github.com/grafana/dskit/runtimeconfig"
2829
"github.com/grafana/dskit/server"
@@ -1384,6 +1385,15 @@ func (t *Loki) initMemberlistKV() (services.Service, error) {
13841385
)
13851386
dnsProvider := dns.NewProvider(util_log.Logger, dnsProviderReg, dns.GolangResolverType)
13861387

1388+
var err error
1389+
t.Cfg.MemberlistKV.AdvertiseAddr, err = GetInstanceAddr(
1390+
t.Cfg.MemberlistKV.AdvertiseAddr,
1391+
t.Cfg.Common.InstanceInterfaceNames,
1392+
util_log.Logger,
1393+
)
1394+
if err != nil {
1395+
return nil, err
1396+
}
13871397
t.MemberlistKV = memberlist.NewKVInitService(&t.Cfg.MemberlistKV, util_log.Logger, dnsProvider, reg)
13881398

13891399
t.Cfg.CompactorConfig.CompactorRing.KVStore.MemberlistKV = t.MemberlistKV.GetMemberlistKV
@@ -2015,3 +2025,11 @@ func schemaHasBoltDBShipperConfig(scfg config.SchemaConfig) bool {
20152025

20162026
return false
20172027
}
2028+
2029+
func GetInstanceAddr(addr string, netInterfaces []string, logger log.Logger) (string, error) {
2030+
if addr != "" {
2031+
return addr, nil
2032+
}
2033+
2034+
return netutil.GetFirstAddressOf(netInterfaces, logger, false)
2035+
}

0 commit comments

Comments
 (0)