Skip to content

feat: Spread private service traffic across healthy producers on a node - #1094

Merged
privateip merged 2 commits into
fix/issue-1086-datapathfrom
fix/issue-1086
Oct 25, 2026
Merged

privateip merged 2 commits into
fix/issue-1086-datapathfrom
fix/issue-1086

Conversation

@privateip

@privateip privateip commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

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

  • With real traffic, both producers answer, no request fails while one drains, and the other's connections survive its removal
  • Unhealthy producers drain, all stay eligible when every one is Unhealthy, and reports for an earlier attachment are ignored
  • Endpoints that do not opt in compile and are refused exactly as before
  • Lint, unit, API-server, root kernel and end-to-end suites pass

Third of three, on the datapath in #1093.

Fixes #1086

🤖 Generated with Claude Code

@privateip

Copy link
Copy Markdown
Contributor Author

Validation, run locally on this stack before pushing (base main at 78f1cb3).

On the final commit:

  • golangci-lint run ./... reported 0 issues, as did the run for the edge-provider example. yamlfmt -lint is clean.
  • go test -race ./api/... ./cmd/... ./internal/... with envtest 1.35 assets passed in all 125 packages.
  • scripts/ci.sh unittest-root as root passed in every root-gated package. Those include the datapath program tests, run through the verifier, and the real-packet test, which uses netns and veths with the production attach and route programmer. After the stale-pin fix in the datapath layer, prog, serviceroute, serviceroutemap and attach were rerun as root and pass.
  • task test:e2e on Kind passed.

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:

  • A containerlab or staging check with real multi-producer workloads. The lab has no private service workload, and the PSC fixture covers only a single producer.
  • An end-to-end measurement in a cluster of how long crash detection takes.

privateip and others added 2 commits October 25, 2026 11:28
…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>
@privateip

Copy link
Copy Markdown
Contributor Author

Two independent reviews ran on this PR, and both returned merge with no blocker or warning on its code.

  • The adversarial review built the tree and ran the controller and route unit tests, and they pass. It read the health reconciler, the in-place route replacement, the router wiring and the RBAC. Its one open item was the root kernel suite, which it could not run. CI's root job now passes on this head.
  • The conventions review rendered the router manifests and checked reach and conventions. Its nit about the router's new status permission is now in the body.

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 gh stack merge 1096 --merge once approved.

@privateip
privateip requested a review from a team as a code owner October 25, 2026 15:47

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yaml adds serviceendpoints/status with get/update/patch, which covers the server-side apply Status().Patch. The silent-403 risk from the #1092 review is closed.
  • Single enforcement: validateProducerTopology keeps refusing two ready producers in one node and VPC when the endpoint is not Spread, and spread() is true only for the literal Spread, so an empty distribution behaves 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: replacePolicyLocked applies 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. setState ref-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 SweepPolicy also sweeps. Status entries are removed per node via per-node field managers, relying on the listType=map keys from #1092.

Follow-ups:

  • Stale status after node loss: a dead node's entries stay in status.producers as 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 on lastTransitionTime/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 healthCheck without 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.

@privateip
privateip merged commit f143176 into main Oct 25, 2026
18 checks passed
@privateip
privateip deleted the fix/issue-1086 branch October 25, 2026 16:05
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.

Share private-service traffic across healthy servers

2 participants