Repository navigation
fix: Balance Spread endpoint traffic and keep TCP connections in place - #1223
Conversation
|
Review record for head 60edc50. pr-conventions-reviewer: merge, with nits. The nits were applied in 60edc50 (a comment rewrap in usid.c plus PR body edits). It also noted that open draft #596 edits usid.c; no action taken, since #596 has not been updated since 2026-09-24. pr-adversary: merge. It ran Human decision: on 2026-10-29 the author chose "Ready + auto-merge", after being shown that every required check on 60edc50 had passed (Build, Lint, Unit Tests, Unit Tests (root), E2E Tests). That resolves the decision finding. Local runs by the session on 52f7fab: lint, build, unit, CI on 60edc50: all checks passed, including the root kernel suite. Auto-merge is enabled with the merge method. The main ruleset requires one approving review including a code owner, so the PR still waits for human approval. |
|
Caution Hold this merge. Moderate impact. Why. Merging this changes how a Spread endpoint picks its remote producer, from first-by-name to rendezvous hashing, and the consumer's node and the producer's node each compute that pairing. While galactic-router rolls node by node the two disagree, so the remote consumers whose pairing changed are refused until both nodes run the new version. flowchart LR
A["galactic-router rolling update"] --> B["new node: rendezvous pairing"]
A --> C["old node: first producer by name"]
B --> D["consumer sends to producer X"]
C --> E["producer X installs no half"]
D --> F["requests refused until both nodes upgraded"]
E --> F
Before merging: Install the consumer's producer half when either the old first-by-name rule or the new rendezvous rule selects the producer, ship that alone, and remove the old rule in a later release. Evidence · 5 stepsTrigger: the galactic-router DaemonSet rollout that ships this change, while one node runs the new pairing rule and its peer still runs the old one (Not measurable from this workspace: no galactic-router telemetry is reachable (zero series for container.googleapis.com/container/cpu/usage_time in datum-cloud-prod; the DaemonSet exists in neither connected cluster; reads of namespace galactic-system are denied on the staging cluster). The condition itself fires for every consumer of a Spread + PreferNodeLocal endpoint whose node holds no producer: the new rule keeps the old producer for about 1/E of them, E being the eligible producer count.)
Traffic: No production read supports a rate. datum-cloud-prod returns zero series for container.googleapis.com/container/cpu/usage_time over the last hour, the galactic-router DaemonSet is absent from infrastructure-control-plane-prod (Resource not found) and from the staging cluster (read denied), and the GCP project carries no k8s_container logs. The score rests on the resulting code and on the pull request's own note, which states the refusal. Also considered · 3 refuted
Analysed against 2 cloud accounts and 1 repository
Polylane could not find the cloud resources this repository manages, so this review looked at the entire cloud account. Connect this repository to its resources and the next review will focus on exactly what this code deploys to. Polylane analysed Rate this review: 👍 helpful · 👎 not helpful · 😕 confusing |
ecv
left a comment
There was a problem hiding this comment.
Request changes.
The balancing and pin-less TCP fixes are right, but the rollout drops traffic. During the galactic-cni rolling upgrade (maxUnavailable: 1), about (N-1)/N of remote Spread consumers move from first-by-name to a hashed producer. The consumer's node and the producer's node compute that pairing separately, so the new producer has no half installed until both nodes are upgraded, and the consumer's traffic is dropped. The Polylane production impact check fails on the same trajectory. A paused or partial rollout leaves the drop in place.
- For one release, have the producer node accept a remote Spread consumer under either the old first-by-name pairing or the new hashed one, or install both halves. A rolling upgrade then refuses nothing, and the hashed-only form can follow once every node runs it.
- The rest checks out. usid.c changes no map definition, key or value struct, or pinned name, so the reload keeps pinned maps. Both nodes derive the pairing from the same inputs (FNV-1a over the UIDs plus
mix64over sorted producers), so once upgraded they can't disagree. The rendezvous moves only the consumers a joining or leaving producer gains or loses. - The unit tests cover the stated claims: a pin-less TCP connection stays put after a join, a leave moves only its own flows, and the planner spreads consumers and moves them on Unhealthy.
Follow-ups:
- Add a metric of remote Spread consumers refused for a pairing mismatch, so an operator can tell a stalled rollout from a real fault.
- Smoke-load the program on the oldest production kernel. The added 16-iteration unrolled loops raise verifier cost, and only the CI kernel has loaded them.
A Spread endpoint consumer with no producer on its node was sent to the first producer, by namespace and name, that was not reported Unhealthy. Every such consumer landed on that one producer, and all of them moved together when it flapped. selectProducers now picks the remote producer by rendezvous hashing of the consumer's attachment UID with each producer's UID, or namespace/name for an attachment with no UID. It keeps the existing tiers: producers reported Healthy or Unknown or not reported, then producers whose report expired, then all producers. Each consumer goes to the highest-scoring producer in the first non-empty tier. Consumers spread across the remote producers, and a producer joining, leaving or turning Unhealthy changes the choice only for consumers whose top producer it is. ProgrammingPlan calls the same function, so the nodes it schedules match the intents Compile emits. The consumer's node and the producer's node each compute the pairing. While routers run mixed versions, a remote Spread consumer whose pairing changed is refused until both nodes run this version. Single endpoints are unaffected. TestCompileSpreadSpreadsConsumersAcrossRemoteProducers sends 64 consumers to 4 remote producers and checks that each producer takes some. It then adds a fifth producer, removes one and reports one Unhealthy, and checks that only the consumers gained or lost move. It also compiles on each producer's node and checks that the producer halves match the consumer node's choices. Without the fix, all 64 consumers go to producer-0. Two existing tests that expected the first producer by name now check the same properties without depending on which producer wins, including that a consumer with every report expired goes where it would with no reports. Related to #1097
A LocalSet route keeps a TCP connection on its producer through a pin in service_flow_table. That table is an LRU holding a quarter of service_reverse_table's flows, and a pin also ends after 300 seconds idle. A packet with no live pin was placed by hash % eligible_count. When a producer joined or left after the connection opened, most pin-less connections mapped to a different producer and reset, even though the connection's own reverse row still named its producer. service_select_producer now does three things in order: - A TCP packet with no live pin checks each member of the set for the reverse row this flow's packets left: the reply tuple on that member's interface, in LOCAL mode, for this consumer interface and that member's token, used within the flow timeout. If one matches and the member's interface identity still matches its token, the connection keeps that producer, draining or not, and is pinned again. This uses the same rule as the pin. An opening SYN (SYN without ACK) skips the probe, so a client reusing a recent tuple cannot reach a draining producer. - Only a flow with neither a pin nor a reverse row is placed by hash. The hash is now rendezvous over the eligible members' identity tokens, so a producer joining or leaving moves only the connections it gains or loses. - UDP still picks at random, through the same rendezvous step with a random hash. No map layout changes, so loading this datapath recreates no pinned map. TestUsidServiceEgress_LocalSetKeepsTCPFlowsWithoutPins opens 64 connections across two producers, adds a third and evicts every pin. Each connection must keep its producer. Without the fix, port 44030 moved from producer 50 to producer 1. The test then clears all flow state, adds the third producer again, and checks that each connection either stays or moves to the new producer, then that removing that producer moves only its own connections. TestUsidServiceEgress_LocalSetReverseRowFallback checks that a pin-less connection keeps a draining producer, that an opening SYN on the same tuple goes to an eligible producer, and that a producer whose interface was replaced is skipped. Removing the SYN check or the identity check makes it fail. Related to #1097
One line of the service_select_producer comment ran to 130 columns. This rewraps the paragraph to the width the rest of the file uses. The comment text and the code are unchanged.
The consumer's node and the producer's node each choose a Spread consumer's remote producer. Switching that choice from first-by-name to rendezvous hashing in one release refused every consumer whose pairing changed while routers ran mixed versions, for the whole rolling upgrade. A producer's node now installs a producer half for the producer each pairing picks, whatever its own setting. The consumer's own pairing is chosen by the new --service-spread-pairing (GALACTIC_ROUTER_SERVICE_SPREAD_PAIRING) option, which defaults to first, the previous behavior. Once every node runs this router, setting rendezvous node by node refuses nothing, since every producer node already accepts both pairings. A later release can make rendezvous the default and then drop the first pairing. Applied intents are now keyed by consumer and producer, so the two producer halves of one consumer can coexist on a node. ProgrammingPlan counts the nodes of every accepting producer.
60edc50 to
5b86f2f
Compare
|
Addressed the rollout finding in 5b86f2f, rebased onto main. Accept-both on the producer side alone covers only an old consumer facing an upgraded producer. An upgraded consumer facing an old producer would still be refused, because the old router installs only the first-by-name half. The fix has two parts:
Tests: the spread test now checks that each producer node, under either setting, installs halves for exactly the consumers that either pairing sends to it. The fallback test runs under both pairings, and a controller test covers two producer halves of one consumer coexisting. Local Follow-ups not in this PR:
|
ecv
left a comment
There was a problem hiding this comment.
Approve.
The rollout drop is closed. Producer nodes now install a producer half for the producer each pairing picks, so an old consumer facing an upgraded producer is accepted, and consumers stay on first-by-name by default (--service-spread-pairing, default first), so an upgraded consumer facing an old producer is also unchanged. A rolling or paused upgrade therefore refuses nothing, which covers the case my either-pairing suggestion alone did not.
firstProducermatches main's old selection exactly: first eligible by order, then first expired, thenproducers[0]. Sofirstchanges no consumer's producer on upgrade.- Intents are keyed by
IntentSlot(consumer, producer) so two producer halves of one consumer coexist. The programmer's grant and marker entries are keyed by the producer's own interface, so two halves on one node do not collide.ProgrammingPlancounts every accepting producer's node. - Flipping to
rendezvousafter every node runs this build is drop-free, node by node. The docs say to set it only then. They do not say to set it back tofirstbefore rolling any node back to an older router: after the flip, such a node refuses the rendezvous pairing. Add that sentence. ci / Build and testfailsinternal/edge/masqueTestAgainstCore/stale_delete_keeps_the_replacement(PrefixConflict), a package this diff does not touch. TheCIworkflow's unit, root-kernel and e2e jobs pass at the head; the failed job is re-running.
Follow-ups:
- The mismatch metric is still not added. With accept-both it only fires if
rendezvousis set too early or on a node rolled back, but it is how an operator would tell that from a fault. - The oldest-kernel verifier smoke load is still not done.
usid.ckeeps the 16-iteration unrolled loops, and only the CI kernel has loaded them. Do it before the default flips torendezvous. - With the default at
first, nothing is balanced until someone sets the option. Track the later release that makesrendezvousthe default and dropsfirst.
Summary
A Spread endpoint sent every consumer that had no local producer to the same remote producer, and a TCP connection that lost its flow pin could reset when the set of producers on its node had changed.
A pin-less connection now stays with the producer that already carries it. Remote consumers can spread across the eligible producers by rendezvous hashing, so a producer joining, leaving or turning Unhealthy moves only the consumers and connections it gains or loses.
The remote pairing is chosen by the consumer's node and also by the producer's node, so changing it must not refuse traffic while routers disagree:
--service-spread-pairing/GALACTIC_ROUTER_SERVICE_SPREAD_PAIRING. It defaults tofirst, the previous behavior.ProgrammingPlancounts every accepting producer's node.Note
Rollout: upgrading galactic-router changes no pairing, so a rolling or partial upgrade refuses nothing. Set
rendezvousonly after every node runs this version, since an older router accepts onlyfirst. Flipping the setting node by node is safe once all nodes accept both pairings. A later release can makerendezvousthe default and then dropfirst. Single endpoints are unaffected, and no map layout changes, so the CNI reloads without recreating pinned maps.Test plan
rendezvous, and a join, a leave or an Unhealthy report moves only the consumers that producer gains or losesfirst, every remote consumer goes to the first producer by name, as before--service-spread-pairingdefaults tofirstand rejects unknown valuestask lint,task build,task test:unitand uncachedtask test:e2epass locallyFixes #1097