-
-
Notifications
You must be signed in to change notification settings - Fork 923
Apply DNS host config on change only #4695
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
base: main
Are you sure you want to change the base?
Apply DNS host config on change only #4695
Conversation
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.
Pull Request Overview
This PR optimizes DNS host configuration updates by applying changes only when the configuration has actually changed, preventing unnecessary updates when the config remains identical.
Key Changes:
- Added hash-based change detection to compare current and new DNS host configurations
- Introduced
currentConfigHashfield to track the hash of the applied configuration
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| UseStringer: true, | ||
| }) | ||
| if err != nil { | ||
| log.Errorf("unable to hash the host dns configuration, got error: %s", err) |
Copilot
AI
Oct 24, 2025
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.
When hashing fails, the error is logged but execution continues with hash being 0. This could cause incorrect behavior where a zero hash might spuriously match s.currentConfigHash (which is also initialized to 0), preventing the first configuration from being applied. Consider returning early or setting a flag to force application when hashing fails.
| log.Errorf("unable to hash the host dns configuration, got error: %s", err) | |
| log.Errorf("unable to hash the host dns configuration, got error: %s", err) | |
| return |
| } | ||
|
|
||
| if s.currentConfigHash == hash { | ||
| log.Infof("not applying host config as there are no changes") |
Copilot
AI
Oct 24, 2025
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.
[nitpick] Changed 'Infof' to 'Debugf' for consistency with logging levels - configuration skip events are typically debug-level information rather than info-level.
| log.Infof("not applying host config as there are no changes") | |
| log.Debugf("not applying host config as there are no changes") |
|



Describe your changes
Host config should only be applied when it has changed
Issue ticket number and link
Stack
Checklist
Documentation
Select exactly one:
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
https://github.com/netbirdio/docs/pull/__