fix(gateway): withdraw advertisements when a gateway node is removed - #420
Merged
Conversation
Deleting a gateway node's NetworkGateway stopped its datapath engine and marked it Terminating, but never withdrew the BGPAdvertisements it had created: its self-address route and its per-rule, per-address-family VIP routes. The route stayed in the mesh advertising a node with nothing behind it, so traffic kept being drawn toward a node that could no longer serve it, while every control plane signal an operator would check still said the route was healthy. This is issue #367's teardown fix in reverse. That fix made rule deletion withdraw every advertisement a rule caused, regardless of which node created it, discovered by listing on a label rather than reconstructing names from the namespace's current gateway-node membership -- a node that was registered when the rule was created and has since left would otherwise never be found. The same blind spot existed here in the other direction: nothing withdrew every advertisement a node caused when that node left, including advertisements for rules that had themselves already been deleted. Added withdrawNodeAdvertisements, which lists BGPAdvertisements in the namespace and deletes the ones name-qualified for the departing node -- its self-address advertisement and every "<rule>-<node>-v4"/"-v6" it created. It's wired into the NotFound branch of Reconcile (the path that actually runs in production, since NetworkGateway carries no finalizer, so the object is already gone by the time any process observes the deletion) keyed on the departed node's own name from the request, since the node whose advertisements need withdrawing is usually the one whose own process is already gone. It's also wired into the DeletionTimestamp branch for defense in depth, ordered before Engine.Stop so there's never a window where forwarding is gone but the route is still advertised. Fixes #406 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ecv
approved these changes
Aug 16, 2026
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
When a gateway node was removed, the BGPAdvertisements it created — its self-address route and its per-rule VIP routes — stayed in the BGP mesh with no forwarding behind them. Traffic kept being drawn toward a node that could no longer serve it, while every control plane signal an operator would check still reported the route as healthy. This is issue #367's teardown fix in the other direction: that fix withdrew a deleted rule's advertisements regardless of which node made them; this withdraws a departed node's advertisements regardless of which rule they were for.
Test plan
Fixes #406