Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not update lighthouse ips if dns lookup failed #1184

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion remote_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,17 @@ func NewHostnameResults(ctx context.Context, l *logrus.Logger, d time.Duration,
ticker := time.NewTicker(d)
go func() {
defer ticker.Stop()
var lookupSuccess bool
for {
lookupSuccess = true
netipAddrs := map[netip.AddrPort]struct{}{}
for _, hostPort := range r.hostnames {
timeoutCtx, timeoutCancel := context.WithTimeout(ctx, r.lookupTimeout)
addrs, err := net.DefaultResolver.LookupNetIP(timeoutCtx, r.network, hostPort.name)
timeoutCancel()
if err != nil {
l.WithFields(logrus.Fields{"hostname": hostPort.name, "network": r.network}).WithError(err).Error("DNS resolution failed for static_map host")
lookupSuccess = false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for correctness, the default would need to be false and toggle this to true when err == nil. This is because if we try to resolve multiple hostnames for a given Nebula IP, and one fails and another succeeds, we'd like to use the results from the successful query.

continue
}
for _, a := range addrs {
Expand All @@ -149,7 +152,7 @@ func NewHostnameResults(ctx context.Context, l *logrus.Logger, d time.Duration,
}
}
}
if different {
if different && lookupSuccess {
l.WithFields(logrus.Fields{"origSet": origSet, "newSet": netipAddrs}).Info("DNS results changed for host list")
r.ips.Store(&netipAddrs)
onUpdate()
Expand Down
Loading