Repository navigation
feat: Spread private service traffic across healthy producers on a node - #1094
Conversation
|
Validation, run locally on this stack before pushing (base main at 78f1cb3). On the final commit:
The real-packet test has thresholds that were chosen before it ran. Both producers must answer, no request may fail while one producer drains, and pinned TCP connections must keep their producer. Over six runs, 200 UDP requests from one socket split between 97/103 and 121/79. During each drain, 28,000 to 34,000 requests ran with 0 failures. The API and datapath layers were each checked on their own with lint, build and the unit suite under race, and all 125 packages passed. The datapath layer was amended afterwards, but only its program and that program's test changed. The root run on the final commit covers both. These were not run:
|
11aaf0c to
1787529
Compare
…a node An endpoint that selects two ready producers on one node and VPC is refused for every consumer on every node, because each consumer's route names one producer. Services that run several replicas per node, such as private DNS resolvers, therefore expose one address per replica and let clients pick, which loads the first replica and stalls lookups for as long as clients take to time out on it during a rollout. For an endpoint with distribution Spread, galactic-router now: - probes each producer on its own node over TCP, from the host-side interface's link-local address to the attachment's first IPv6 address, reusing the gateway's healthprobe loop, and applies those producers' decisions to the endpoint's status.producers under a per-node field manager, seeding each loop from the published decision after a restart; - compiles each consumer into one LocalSet intent holding every producer on its node, the Unhealthy ones draining unless all are, and falls back to one remote producer not reported Unhealthy when the node has none and PreferNodeLocal allows it; - programs the intent as a LocalSet route and producer set, applying a changed intent before removing the old one and keeping the newest set of a key in the map, so a health or membership change never removes the consumer's route and only a departing producer's connections move; - refuses LocalSet intents, and only those, while the node's datapath has no producer set map; - counts its producers by state in galactic_service_route_producers. The router needs patch on serviceendpoints/status. Single endpoints compile and program exactly as before. The operator guide documents the field, the probe, the drain sequence and the rollout order, and a root-gated test drives real UDP and TCP traffic through the production classifier to two producers, drains one while requests flow and removes it. Resolves: #1086 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A TCP connection on a Spread endpoint stays with its producer only while its flow pin lasts. The operator guide now says when a pin ends and what happens to a connection that loses it, that a remote consumer of a Spread endpoint reaches a single producer and can be refused briefly while the two nodes disagree on its health, and that switching an endpoint between Single and Spread replaces its routes. It also says to set every endpoint back to Single before rolling back galactic-cni, not only galactic-router: the producer set map's pin outlives a datapath rollback, so a newer router keeps writing Spread routes that the older datapath drops. Related to #1086 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1787529 to
a2cc62a
Compare
|
Two independent reviews ran on this PR, and both returned merge with no blocker or warning on its code.
Since those reviews, the PR was only restacked onto the datapath fix. Its two commits are unchanged. CI is green on this head, including the root kernel and end-to-end jobs. This is the top of stack #1096, which merges as a whole with |
ecv
left a comment
There was a problem hiding this comment.
Approve.
The router now writes status.producers with the RBAC it needs, probes producers with hysteresis, and drains rather than drops unhealthy ones, so in-flight connections survive health changes. Single behaviour is unchanged and nothing deploys on merge.
- RBAC:
config/galactic-router/rbac.yamladdsserviceendpoints/statuswith get/update/patch, which covers the server-side applyStatus().Patch. The silent-403 risk from the #1092 review is closed. - Single enforcement:
validateProducerTopologykeeps refusing two ready producers in one node and VPC when the endpoint is not Spread, andspread()is true only for the literalSpread, so an emptydistributionbehaves as Single without a CRD default. A Spread endpoint is refused above 16 ready producers on one node. - Health state: unhealthy producers become
Draining(existing flows and replies kept, no new flows), and when all local producers are Unhealthy all stay eligible so new flows are not blanket-dropped. Probes use interval/timeout plus unhealthy/healthy thresholds (default 3/3), which damps flapping, and a restarted router seeds from the published decision so it does not reshuffle the set. - Set changes:
replacePolicyLockedapplies the new LocalSet intent before removing the old one, with a fallback to remove-then-apply, so the consumer route never disappears and flows to producers that stay keep going.setStateref-stacking restores the older set if the newer release fails. - Cleanup: leaving Spread (or deleting the endpoint or healthCheck) releases the probes, publishes an empty list for this node's field manager, and releases the producer set, which
SweepPolicyalso sweeps. Status entries are removed per node via per-node field managers, relying on thelistType=mapkeys from #1092.
Follow-ups:
- Stale status after node loss: a dead node's entries stay in
status.producersas their last state (probably Healthy), and nothing ages them out. Remote consumers would keep being sent to a producer on a dead node. Consider a staleness bound onlastTransitionTime/heartbeat, or ignoring entries whose node is NotReady. - Spread only spreads within the consumer's node. A consumer on a node without producers (PreferNodeLocal) gets the first non-Unhealthy remote producer, so all such consumers pile onto one remote producer, and a flap of that one moves their routes at once.
- Probes are TCP connects only, so a UDP-only Spread endpoint is judged by a TCP port it may not listen on. State this in the docs or reject
healthCheckwithout a TCP port. - Health is probed by every node for its own producers only; if the router is down but the producer is up, a stale Unhealthy entry would drain it indefinitely.
Summary
An endpoint that selects two ready producers on one node is refused for every consumer, so services such as private DNS expose one address per replica and clients stall on the first one during a rollout.
For an endpoint that opts in, each node now probes its own producers and reports their health, and each consumer's route carries every producer on its node, where an Unhealthy one takes no new traffic but keeps its open connections.
A health or membership change replaces the route without removing it, so only a departing producer's connections move.
Before opting an endpoint in, roll out the CNI and grant the router its new permission to update endpoint status, including in any copy of its role a deployment keeps, and set endpoints back to the default before rolling back either the CNI or the router.
Test plan
Third of three, on the datapath in #1093.
Fixes #1086
🤖 Generated with Claude Code