You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
net: adopt and acknowledge node assignments in the agent - #917
Have the node agent adopt its Site and GatewayPool assignment once per process and acknowledge it.
Adoption. At startup, the agent reads its own Node and fixes the Site and GatewayPool for the life of the process. Managed CNI setup is tied to that assignment. Gateways still get their CNI configuration from the Site.
Acknowledgment. After its first successful reconciliation, the agent records the assignment it is running on its own Pod. The controller from net: publish node assignments and replace stale agents #916 uses this to replace outdated agents.
Startup-only Node watch:
The agent watches only its own Node, from adoption until the acknowledgment is saved. The watch uses a field selector and starts from a validating GET.
Any of these restarts the container: a UID, Site or pool change, or the Node being deleted.
This prevents an agent whose first reconciliation keeps failing from being stuck on an old assignment, a case the controller skips because the Pod hasn't acknowledged.
The watch stops once the acknowledgment is written, so no long-lived Node watch remains.
Taint removal. When a gateway is demoted, removing its taint retries only on patch races, with a capped exponential backoff. An admission denial is returned immediately.
Testing
Unit tests for:
adoption and acknowledgment ownership
startup watch cancellation and revalidation after a disconnect
which taint-removal errors are retried, and the retry limits
Tested on an isolated AKS cluster with remote workers:
Set a GatewayPool label that didn't exist, so the agent couldn't acknowledge.
Removed the label. The startup watch restarted the container without the controller replacing the Pod, and the agent then acknowledged the correct assignment.
Audit logs showed every watch on the agent's own Node closed. The last one closed 1.8 ms after the acknowledgment.
Stack
This is one of five stacked PRs that reduce API server load from unbounded-net-controller and unbounded-net-node. Kubernetes remains the source of truth. Review them bottom to top:
Motivation. A large cluster running v0.8.0 had the controller continuously writing objects that hadn't changed. Every node agent also watched the whole cluster's gateway topology. On a canary cluster, the full stack cut controller API calls by 54.4% and node agent API calls by 73.8%.
Pins each node agent’s assignment for its process lifetime and acknowledges it for controller-driven replacement, supporting the API-load reduction stack.
Changes:
Adopt assignments and monitor changes until acknowledgment succeeds.
Tie CNI setup and transition cleanup to the adopted assignment.
Add bounded taint-removal retries and lifecycle tests.
Throttle watch reconnects when no Site assignment exists
cmd/unbounded-net-node/assignment.go:299
While a Node has no Site assignment, a closed watch or watch.Error event immediately starts another GET/WATCH cycle (lines 206 and 257-299). Repeated error events or immediate stream closures therefore cause an unthrottled request and warning-log loop on each affected agent. Call waitForAssignmentRetry after stopping the watch, as watchAdoptedAssignment already does, so reconnects are delayed and cancellation remains responsive.
Fixed the latest review body's previously missed reconnect-throttling issue in bdc9069. Unassigned Node watches now wait for the cancellation-aware retry interval after closed streams, watch errors or deletion before issuing another GET/WATCH. Regression tests cover immediate closures and error events without a reconnect storm.
Pin Site and GatewayPool membership for the agent lifetime, acknowledge the effective values, and fence managed CNI bootstrap to the adopted Node assignment while retaining Site-driven gateway CNI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ab9b78ee-42b8-4841-8d74-cd78d002d48b
Monitor only the own Node from adoption through bootstrap and initial reconciliation, cancel startup on assignment or identity changes independently of dataplane success, and stop the watch after effective acknowledgment is persisted. Revalidate after disconnects and preserve mismatch causes without allowing stale acknowledgments.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ab9b78ee-42b8-4841-8d74-cd78d002d48b
Retry only patch races (conflicts and failed JSON patch tests) with capped
exponential backoff, and return admission denials immediately instead of
spinning until the cleanup context expires.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ab9b78ee-42b8-4841-8d74-cd78d002d48b
Wait for reconciliation and heartbeat workers before cleanup, clear all advertised routes, retry stale gateway taint cleanup before acknowledgment, and disable the managed conflist only on a managed-to-unmanaged Site transition.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ab9b78ee-42b8-4841-8d74-cd78d002d48b
Create health gates before waiting for the Site label without starting topology watches early. Preserve non-owned gateway taint tuples during worker cleanup.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ab9b78ee-42b8-4841-8d74-cd78d002d48b
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
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
Have the node agent adopt its Site and GatewayPool assignment once per process and acknowledge it.
Testing
Stack
This is one of five stacked PRs that reduce API server load from unbounded-net-controller and unbounded-net-node. Kubernetes remains the source of truth. Review them bottom to top:
Motivation. A large cluster running v0.8.0 had the controller continuously writing objects that hadn't changed. Every node agent also watched the whole cluster's gateway topology. On a canary cluster, the full stack cut controller API calls by 54.4% and node agent API calls by 73.8%.