fix(tailscale): debounce misleading first-boot auth-failed status#494
Open
mvanhorn wants to merge 1 commit into
Open
fix(tailscale): debounce misleading first-boot auth-failed status#494mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
During first boot Tailscale briefly reports NeedsLogin with no auth URL while the auth key is still being processed. classifyState maps that combination directly to a terminal AuthFailed event, surfacing a misleading 'stale state / auth failed' message even though the node reaches Running moments later (almeidapaulopt#478). Add a small grace window in StatusWatcher.Watch: count consecutive NeedsLogin-with-empty-authURL polls and emit a benign Starting status until the streak persists past firstBootAuthGraceCycles, only then forwarding AuthFailed. Any other observed state resets the streak, so genuinely-bad auth keys are still surfaced. classifyState stays pure. Refs almeidapaulopt#478
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On every first boot, tsdproxy logs a scary, terminal-sounding status:
tailscale is in NeedsLogin state without an auth URL. This indicates stale tsnet state ... Restart tsdproxy to auto-recover(#478). The node is actually authenticating fine and reachesRunningmoments later, so the message is misleading.The cause is in
internal/proxyproviders/tailscale/status_watcher.go. During the brief first-boot window,lc.Status()reports backend stateNeedsLoginwith an emptyauthURLbecause the auth key has not been processed yet.classifyStatemaps that combination straight to a terminalmodel.ProxyStatusAuthFailedevent, which is what surfaces as the alarming message.This change keeps
classifyStatepure and adds a small debounce inStatusWatcher.Watch: it counts consecutiveNeedsLogin-with-empty-authURLpolls and emits the benignProxyStatusStartingstatus until the streak persists past a grace threshold (firstBootAuthGraceCycles, default 3 poll cycles). Only once the threshold is crossed does it forwardProxyStatusAuthFailed. Any other observed state (or a non-emptyauthURL) resets the counter. The default is an internal constant, soNewStatusWatcherand thenode_lifecycle.gocall sites need no signature change.Why this matters
The maintainer flagged this twice in the thread: the node was confirmed to be authenticating correctly, and the conclusion was that the status watcher polls during the normal first-boot
NeedsLoginwindow and emits a misleading message that should be improved. Genuinely-bad auth keys are not masked, because aNeedsLogin-with-no-authURLstate that persists past the grace window still surfacesAuthFailedwith the existing error message.Testing
go test ./internal/proxyproviders/tailscale/...(and-race) pass.Runningemits noAuthFailed; a persistedNeedsLogin-no-authURLstate still surfacesAuthFailed; an alternating sequence resets the streak and never trips the threshold prematurely.classifyStatetable tests are unchanged and still pass.Refs #478