[refactor] split routeWatcher into watcher and handler components#797
Open
aritrbas wants to merge 1 commit intonsk-split-svcfrom
Open
[refactor] split routeWatcher into watcher and handler components#797aritrbas wants to merge 1 commit intonsk-split-svcfrom
aritrbas wants to merge 1 commit intonsk-split-svcfrom
Conversation
9763990 to
eeacc54
Compare
sknat
reviewed
Oct 17, 2025
Collaborator
sknat
left a comment
There was a problem hiding this comment.
thanks ! A few comments inline,
I think we could split the uplink_route_watcher in half and simplify the logic even more,
tell me if things are unclear !
Comment on lines
151
to
152
| netWatcher.RegisterRouteWatcher(routeWatcher) | ||
| felixServer.RegisterRouteWatcher(routeWatcher) |
Collaborator
There was a problem hiding this comment.
I think it would be good to split the routeWatcher into two pieces:
- the watching part (i.e. the
WatchRoutes()) function - a
routeHandlercomponent (mostlyOnNetDeleted;OnNetAddedOrUpdatedandOnIpamConfChanged)
The latter could be instantiated in the felixServer, and called synchronously whenever events are received. This would remove the need for us pass therouteWatcherto thenetWatcherof thefelixServer
Collaborator
There was a problem hiding this comment.
This should allow us to remove the NetDeleted and NetAddedOrUpdated events,
and replace them with eventChan <- NetAddedOrUpdated{} and eventChan <- NetDeleted{}
Signed-off-by: Aritra Basu <aritrbas@cisco.com>
eeacc54 to
4574268
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.
This refactors the
RouteWatchercomponent by separating the route watching functionality from the route handling logic.Previously, the
RouteWatcherused to (i) monitor netlink route updates and address changes and (ii) respond to network and IPAM configuration events via pubsub. Because of this, theRouteWatcherneeded to be passed to theNetWatcherjust so it could subscribe to events, and the event handling logic was mixed with route watching logic.Now, we have a new handler component
RouteHandlerthat implements three event handling methods:OnNetDeleted(netDef *common.NetworkDefinition) errorOnNetAddedOrUpdated(netDef *common.NetworkDefinition) errorOnIpamConfChanged(oldPool, newPool *proto.IPAMPool) errorand holds a reference to
RouteWatcherto perform route operations.The
RouteWatcheris now purely focused on route watching. It no longer subscribes to pubsub or performs any event handling. It is only responsible for netlink route/address monitoring.NetWatcherand IPAM configuration changes now directly call theRouteHandlerinstead of sending pubsub events resulting in network and IPAM events being synchronously processed when they occur.NetWatcherno longer needs to know aboutRouteWatcher, it only knows about theRouteHandlerinterface.Events are now processed directly:
NetWatcher→RouteHandler→RouteWatcherPreviously:
NetWatcher→SendEvent→PubSub→RouteWatcher.eventChan→RouteWatcherMade the changes on top of the nsk-split-svc branch for now, will rebase on top of master once those commits for single thread agent are merged.