-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[client] scope macOS DNS state keys by WireGuard interface name #5504
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
Open
siriobalmelli
wants to merge
2
commits into
netbirdio:main
Choose a base branch
from
siriobalmelli:fix/dns-iface-scoping-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't continue past a failed interface checkpoint.
This is the only state write that happens before we create any scoped
NetBird-<iface>-*keys. If it fails and we keep going, an unclean restart can end up with no persistedInterfaceName, andCleanup()then falls back to legacy non-scoped discovery only, leaving the new scoped keys behind.🩹 Proposed fix
if err := stateManager.UpdateState(&ShutdownState{ InterfaceName: s.interfaceName, }); err != nil { - log.Errorf("failed to update shutdown state: %s", err) + return fmt.Errorf("update dns shutdown state: %w", err) }📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a false positive — no code change needed. Here's why:
UpdateStatecan only fail if the state was never registered — the sole error path insetState()iserrStateNotRegistered, which is a programming bug, not a runtime condition. If it fails here, every subsequentUpdateStatecall in this function (lines 95, 117, 127 vias.updateState(stateManager)) will also fail, so returning early from this one call doesn't improve the situation.Codebase convention is log-and-continue — 9 of 10
UpdateStatecall sites across the codebase (routemanager,engine_ssh,dns/systemd_linux,dns/network_manager_unix,dns/resolvconf_unix,dns/host_windows,updatemanager, etc.) all uselog.Errorf/log.Warnfand continue. Changing just this one call to return an error would be inconsistent.The
updateState()helper at line 136 also logs-and-continues — even if we returned early here, the same non-fatal pattern is used for all subsequent state updates in this function. Making only the first call fatal while the rest are non-fatal is incoherent.Returning an error here would break DNS entirely —
applyDNSConfigis the function that configures the client's DNS. Returning early because state persistence failed means DNS won't be configured at all, which is strictly worse than the theoretical risk of orphaned keys on an unclean shutdown.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@siriobalmelli, you're right — I accept all four points. TheerrStateNotRegisteredpath is a programming invariant (not a runtime condition), and blocking DNS configuration because of a state-persistence failure would be strictly worse than the theoretical risk of orphaned keys. The log-and-continue pattern is consistent with the rest of the codebase. I'll retract this comment.✏️ Learnings added
🧠 Learnings used