Skip to content

fix: Withdraw a load balancer rule's route after the rule is deleted - #766

Merged
privateip merged 1 commit into
mainfrom
fix/issue-763
Oct 7, 2026
Merged

privateip merged 1 commit into
mainfrom
fix/issue-763

Conversation

@privateip

@privateip privateip commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A gateway node could keep advertising a load balancer rule's address for a few seconds after the rule was deleted, while no node served it, because its cache had not yet seen the deletion.

Teardown now checks the API server directly before it releases the rule, and deletes and rechecks any route its cache missed.

Each gateway node also withdraws its own routes for rules that no longer exist, on the same pass that unloads the rule, after the API server confirms the rule is gone.

Builds on #765, and the new cleanup works with its renamed routes.

Test plan

  • Deleting a rule whose route the cache missed keeps the rule until that route is withdrawn
  • A node withdraws its own route for a deleted rule and leaves other nodes' routes alone
  • A rule missing from the cache but present in the API keeps its route
  • Unit tests, build, and lint pass

Fixes #763

🤖 Generated with Claude Code

@privateip privateip self-assigned this Oct 7, 2026
@privateip privateip changed the title fix: Withdraw a stale-cache gateway route when its rule is deleted fix: Withdraw a load balancer rule's route after the rule is deleted Oct 7, 2026
A gateway node working from a stale cache could create a BGPAdvertisement for a NetworkRule after NetworkRuleReconciler.reconcileDelete had listed the rule's advertisements, so the finalizer came off with that route still advertised. Since #758 the advertisement carries an owner reference to the rule and Kubernetes garbage collection eventually deletes it, but until then the fabric keeps sending VIP traffic to a node that has already unloaded the rule.

Two windows close here. reconcileDelete still deletes what its cache sees, then lists the rule's advertisements again through the manager's uncached API reader; any found there are deleted and the rule is requeued after 1s, keeping the finalizer until a pass finds none. On the creating side, NetworkGatewayReconciler now runs sweepOrphanedAdvertisements on every pass: it lists this node's own advertisements by gateway-node label and deletes each one whose rule is missing from the pass's rule list and returns NotFound from the uncached reader. A rule the cache has not caught up with keeps its route. The sweep runs on the same pass that unloads the rule from the datapath, so a node that created a late advertisement withdraws it as soon as its cache drops the rule. The owner reference stays as the last resort.

Both reconcilers take a required APIReader, wired to mgr.GetAPIReader() in galactic-gateway. A sweep failure is returned for retry and does not change the gateway's Ready condition. ARCHITECTURE-GATEWAY.md describes both changes.

Fixes #763

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@privateip
privateip marked this pull request as ready for review October 7, 2026 01:31
@privateip
privateip requested a review from a team as a code owner October 7, 2026 01:31
@privateip
privateip enabled auto-merge October 7, 2026 01:31
@privateip

Copy link
Copy Markdown
Collaborator Author

pr-rereviewer VERDICT: merge. Rebase pass shows no breakage; tests pass at new head.
pr-conventions-reviewer VERDICT: merge. Commit and body reach staging by normal path.

Applied findings: Rewrote PR body to replace NOTE callout with one plain sentence about building on #765 (finding 1), and amended the commit subject to "fix: Withdraw a load balancer rule's route after the rule is deleted" to match the PR title (finding 2). Both committed.

pr-rereviewer ran: git log --show-signature; git range-diff; go build ./...; go vet ./internal/controller/ ./cmd/galactic-gateway/; go test ./internal/controller/
pr-conventions-reviewer ran: gh pr view; git diff --stat; gh pr list; gh pr view 765; grep CONVENTIONS.md; git log; git diff of controller files.

All CI checks passed: Build, Lint, Unit Tests, E2E Tests, and publish workflows all green.

Merge method: merge (the only method the main ruleset allows). Auto-merge enabled and waits for approvals, which the review ruleset requires (1 approving review plus code owner review plus last-push approval; dismiss stale reviews on push).

Note: Open PRs #761 and #738 also edit docs/agents/ARCHITECTURE-GATEWAY.md in different sections, so whichever merges second will need a rebase.

@privateip
privateip merged commit 1626611 into main Oct 7, 2026
14 checks passed
@privateip
privateip deleted the fix/issue-763 branch October 7, 2026 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stale-cache advertisement can stay advertised after its NetworkRule is deleted

2 participants