[management] Increment newtork serial on peer update#5051
Conversation
Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com>
Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com>
# Conflicts: # management/server/user.go
📝 WalkthroughWalkthroughThe changes modify network serial increment timing in peer and user update flows. In Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @management/server/peer.go:
- Around line 272-274: UpdatePeer currently always calls
transaction.IncrementNetworkSerial(ctx, accountID) which causes a network serial
bump on every update; change this to only increment when actual peer data
changed by guarding the call with a condition that checks the existing change
flags (peerLabelChanged, sshChanged, loginExpirationChanged,
inactivityExpirationChanged). Locate the IncrementNetworkSerial invocation in
UpdatePeer and wrap it so it runs only if at least one of those boolean flags is
true (or add a combined “anyChanged” variable computed from them) so network map
updates only occur on real changes.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
management/server/peer.gomanagement/server/user.go
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-28T12:20:47.254Z
Learnt from: bcmmbaga
Repo: netbirdio/netbird PR: 4849
File: management/internals/modules/zones/manager/manager.go:55-86
Timestamp: 2025-11-28T12:20:47.254Z
Learning: In the NetBird management server, DNS zones without records are automatically filtered out in network map generation (filterPeerAppliedZones in management/internals/controllers/network_map/controller/controller.go checks `len(zone.Records) == 0`). Therefore, CreateZone operations don't need to call UpdateAccountPeers since empty zones don't affect the network map.
Applied to files:
management/server/peer.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Client / Unit
- GitHub Check: release
🔇 Additional comments (1)
management/server/user.go (1)
580-585: LGTM! Correctly prevents double network serial increment.The conditional logic now ensures that when peers are expired,
expireAndUpdatePeershandles both the network serial increment (line 996) and peer updates. When no peers need expiring, the serial is incremented here andUpdateAccountPeersis called. This prevents the double increment and double peer update that would have occurred previously when both conditions were true.



Describe your changes
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/__
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.