Skip to content

Commit

Permalink
Add logging for InferLocalAddr
Browse files Browse the repository at this point in the history
  • Loading branch information
flawedmatrix committed Apr 12, 2024
1 parent 1157ba3 commit 5a19043
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server/embed/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1154,14 +1154,28 @@ func (cfg *Config) InferLocalAddr() string {
if !cfg.SetMemberLocalAddr {
return ""
}

lg := cfg.GetLogger()
lg.Info(
"searching for a suitable member local address in AdvertisePeerURLs",
zap.Strings("advertise-peer-urls", cfg.getAdvertisePeerUrls()),
)
for _, peerURL := range cfg.AdvertisePeerUrls {
if addr, err := netip.ParseAddr(peerURL.Hostname()); err == nil {
if addr.IsLoopback() || addr.IsUnspecified() {
continue
}
lg.Info(
"setting member local address",
zap.String("LocalAddr", addr.String()),
)
return addr.String()
}
}
lg.Warn(
"unable to set a member local address due to lack of suitable local addresses",
zap.Strings("advertise-peer-urls", cfg.getAdvertisePeerUrls()),
)
return ""
}

Expand Down

0 comments on commit 5a19043

Please sign in to comment.