ipn/ipnlocal: reduce excessive logging of exit node suggestions (#20237)

The logging added in 12188c0 was generating excessive spam in
backend logs. This may have been exacerbated by
tailscale GUI<->backend architecture on certain platforms like
Windows, where the GUI polls for exit node suggestions rather
than listening on the IPN bus.

Change this to log on error or if the current suggestion differs
from the previous suggestion.

Updates tailscale/corp#43691
Updates #20194

Signed-off-by: Amal Bansode <amal@tailscale.com>
This commit is contained in:
Amal Bansode
2026-06-24 08:40:23 -07:00
committed by GitHub
parent d4f2917c1b
commit c33a55737b

View File

@@ -8851,6 +8851,8 @@ func fillAllowedSuggestions(polc policyclient.Client) (set.Set[tailcfg.StableNod
// preferredDERP is this device's home DERP region (0 if unknown) and
// regionLatency is the best recent latency to each DERP region; both come from
// netcheck and are only used by the DERP-based algorithm.
//
// Errors are always logged. Suggestions are logged if they defer from prevSuggestion.
func suggestExitNode(preferredDERP int, regionLatency map[int]time.Duration, nb *nodeBackend, prevSuggestion tailcfg.StableNodeID, selectRegion selectRegionFunc, selectNode selectNodeFunc, allowList set.Set[tailcfg.StableNodeID]) (res apitype.ExitNodeSuggestionResponse, err error) {
switch {
case nb.SelfHasCap(tailcfg.NodeAttrTrafficSteering):
@@ -8865,8 +8867,10 @@ func suggestExitNode(preferredDERP int, regionLatency map[int]time.Duration, nb
if err != nil {
nb.logf("netmap: suggested exit node: %v", err)
} else {
name, _, _ := strings.Cut(res.Name, ".")
nb.logf("netmap: suggested exit node: %s (%s)", name, res.ID)
if res.ID != prevSuggestion {
name, _, _ := strings.Cut(res.Name, ".")
nb.logf("netmap: suggested exit node: %s (%s)", name, res.ID)
}
}
return res, err
}