Skip to content

feat(agent): build udp: cluster entries for PROTOCOL_UDP services - #935

Merged
bpalermo merged 1 commit into
mainfrom
feat/udp-agent-xds-v2
Sep 25, 2026
Merged

bpalermo merged 1 commit into
mainfrom
feat/udp-agent-xds-v2

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Third of the #931 series. #934 made the control plane carry a UDP service; this makes the node agent build its Envoy cluster.

Without this, a UDP-only service has no data path at all

LoadClustersFromRegistry listed HTTP and TCP only, so a service registered solely under PROTOCOL_UDP produced no cluster entry. udpClusterForLocked deliberately refuses to name a cluster the snapshot does not carry — naming one would accept datagrams and drop them in silence — so captureUDPClusters emitted nothing and the per-pod udp_proxy listener was never built.

The datagram path did not exist rather than being broken, and nothing said so.

The rename is most of the change

clusterEntry.tcp gated two behaviours:

site behaviour
clustersEndpointsAndVhosts emit only the bare-name CLA — no h2 cluster, no outbound vhost
refreshEntryMTLSLocked skip upstream mTLS injection

Both are already right for UDP, for different reasons: TCP floor entries skip mTLS because the floor cluster carries its own transport socket; UDP because there is none — the floor is plaintext and mTLS has no DTLS counterpart.

So both sites were protocol-agnostic in behaviour and only the name claimed otherwise. Renamed to l4Floor, and UDP needed no new branch at either.

buildUDPClustersLocked is deliberately thinner than its TCP sibling: no sanNamespaces, no per-port entries. Both would be lies — there is no peer identity to pin on a plaintext hop, and a connection-less UDP listener carries no filter chains to name a per-port cluster from.

serviceEntryLocked gains a third arm (HTTP → TCP → UDP). The order is a preference, not a priority: a service under several protocols has the same endpoints under each and only one entry owns the bare-name CLA. The UDP arm exists for the service registered only as PROTOCOL_UDP.

Worth a look in review

The sni assertion in the new test is load-bearing, not cosmetic:

assert.Equal(t, "9001", udpEntry.sni, "sni carries the registered application port")

captureUDPClusters parses sni to rewrite the load assignment onto the datagram port, and an entry whose sni does not parse is skipped — which is exactly the silent-no-listener path this PR exists to close.

Test fixture note

The new test's mock switches on protocol explicitly. The existing fixtures in this package predate a third protocol and use the if TCP … else HTTP shape, so a UDP call lands in their HTTP branch. Harmless there — the HTTP entry owns the CLA, so the spurious UDP entry carries nil and emits nothing — but it is the same open-set shape that actually broke the registrar syncer test in #934, so new code does not copy it.

Verification

bazel test //... — 109/109. Lint clean. Refs #931.

Still to come: PR4 (app ports + the health fix — #931's actual fix, which I will validate on talos-main before merging), PR5 (make the silent drop loud), PR6 (e2e).

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Third of the #931 series. #934 made the control plane carry a UDP service; this
makes the node agent build its Envoy cluster.

WITHOUT THIS, A UDP-ONLY SERVICE HAS NO DATA PATH AT ALL

LoadClustersFromRegistry listed HTTP and TCP only, so a service registered
solely under PROTOCOL_UDP produced no cluster entry. udpClusterForLocked
deliberately refuses to name a cluster the snapshot does not carry -- naming one
would accept datagrams and drop them in silence -- so captureUDPClusters emitted
nothing and the per-pod udp_proxy listener was never built. The datagram path
did not exist rather than being broken, and nothing said so.

THE RENAME IS MOST OF THE CHANGE

clusterEntry.tcp gated two behaviours: "emit only the bare-name CLA, no h2
cluster or outbound vhost" (clustersEndpointsAndVhosts) and "skip upstream mTLS
injection" (refreshEntryMTLSLocked). Both are already right for UDP, for
different reasons -- TCP floor entries skip mTLS because the floor cluster
carries its own transport socket, UDP because there is none: the floor is
plaintext and mTLS has no DTLS counterpart.

So both sites were protocol-agnostic in behaviour and only the NAME claimed
otherwise. Renamed to l4Floor; UDP needed no new branch at either.

buildUDPClustersLocked is deliberately thinner than its TCP sibling: no
sanNamespaces and no per-port entries. Both would be lies. There is no peer
identity to pin on a plaintext hop, and a connection-less UDP listener carries
no filter chains, so there is nothing to name a per-port cluster from.

serviceEntryLocked gains a third arm (HTTP, then TCP, then UDP). The order is a
preference, not a priority: a service under several protocols has the same
endpoints under each and only one entry owns the bare-name CLA. The UDP arm
exists for the service registered ONLY as PROTOCOL_UDP.

TEST FIXTURE NOTE

The new test's mock switches on the protocol explicitly. The existing fixtures
in this package predate a third protocol and use the "if TCP ... else HTTP"
shape, so a UDP call lands in their HTTP branch. That is harmless here (the HTTP
entry owns the CLA, so the spurious UDP entry carries nil and emits nothing),
but it is the same open-set shape that actually broke the registrar syncer test
in #934, so new code does not copy it.

Refs #931

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 63deab3 into main Sep 25, 2026
23 checks passed
@bpalermo
bpalermo deleted the feat/udp-agent-xds-v2 branch September 25, 2026 22: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.

1 participant