[refactor] make BGP peer and secret management system event-driven#790
Open
aritrbas wants to merge 1 commit into
Open
[refactor] make BGP peer and secret management system event-driven#790aritrbas wants to merge 1 commit into
aritrbas wants to merge 1 commit into
Conversation
6fee584 to
2c22c24
Compare
ffb8c29 to
eb5adeb
Compare
sknat
reviewed
Oct 17, 2025
sknat
left a comment
Collaborator
There was a problem hiding this comment.
Many thanks for taking a stab at this !
A couple comments inline, I think there is still room for more untangling of the logic.
Tell me if anything sounds unclear
eb5adeb to
d64a12d
Compare
d64a12d to
4cc6f82
Compare
Signed-off-by: Aritra Basu <aritrbas+gh@cisco.com>
4cc6f82 to
7041ac6
Compare
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
This PR refactors the BGP peer and secret management system from a tightly-coupled handler-based architecture to a loosely-coupled event-driven system.
Changes by Component
1. PeerWatcher (
watchers/peers_watcher.go)cachedPeers map[string]calicov3.BGPPeerPeerAdded- single new peer addedPeerUpdated- single existing peer updatedPeerDeleted- single existing peer deletedPeersChanged- for initial state reconciliation only2. SecretWatcher (
watchers/secret_watcher.go)GetSecret()method (blocking) with eventsSweepStale()method (replaced withOnPeerListUpdated)SecretAdded- new secret availableSecretChanged- existing secret modifiedSecretDeleted- existing secret removedOnPeerListUpdated()- starts watches when peers are added3. PeerHandler (
routing/peer_handler.go)secretCache map[string]map[string]stringOnPeerAdded(peer)- O(1) processing for single peerOnPeerUpdated(old, new)- O(1) diff and updateOnPeerDeleted(peer)- O(1) removalOnSecretAdded(secretData)- cache secret locallyOnSecretChanged(secretName)- mark affected peers for updateOnSecretDeleted(secretName)- remove from cacheProcessPeers()for initial reconciliation only4. FelixServer (
felix/felix_server.go)PeersChanged,PeerAdded,PeerUpdated,PeerDeleted,SecretAdded,SecretChanged,SecretDeletedMade the changes on top of the nsk-split-svc branch for now, will rebase on top of
masteronce those commits forsingle thread agentare merged.