Skip to content

Commit

Permalink
Add logging for InferLocalAddr
Browse files Browse the repository at this point in the history
Signed-off-by: Edwin Xie <[email protected]>
  • Loading branch information
flawedmatrix committed May 1, 2024
1 parent 4831d93 commit 39453ca
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 @@ -1162,14 +1162,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 39453ca

Please sign in to comment.