@@ -23,6 +23,7 @@ import (
23
23
"github.com/grafana/dskit/kv/codec"
24
24
"github.com/grafana/dskit/kv/memberlist"
25
25
"github.com/grafana/dskit/middleware"
26
+ "github.com/grafana/dskit/netutil"
26
27
"github.com/grafana/dskit/ring"
27
28
"github.com/grafana/dskit/runtimeconfig"
28
29
"github.com/grafana/dskit/server"
@@ -1384,6 +1385,15 @@ func (t *Loki) initMemberlistKV() (services.Service, error) {
1384
1385
)
1385
1386
dnsProvider := dns .NewProvider (util_log .Logger , dnsProviderReg , dns .GolangResolverType )
1386
1387
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
+ }
1387
1397
t .MemberlistKV = memberlist .NewKVInitService (& t .Cfg .MemberlistKV , util_log .Logger , dnsProvider , reg )
1388
1398
1389
1399
t .Cfg .CompactorConfig .CompactorRing .KVStore .MemberlistKV = t .MemberlistKV .GetMemberlistKV
@@ -2015,3 +2025,11 @@ func schemaHasBoltDBShipperConfig(scfg config.SchemaConfig) bool {
2015
2025
2016
2026
return false
2017
2027
}
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