Skip to content

test(e2e): TLSRoute and UDPRoute legs for the L4 route harness (#868) - #912

Merged
bpalermo merged 3 commits into
mainfrom
feat/868-l4-route-e2e
Sep 23, 2026
Merged

bpalermo merged 3 commits into
mainfrom
feat/868-l4-route-e2e

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Closes #868.

The kind L4 harness has covered TCPRoute since #879. This adds the TLSRoute and UDPRoute legs, which is the rest of #868's acceptance list.

What runs now

assertion samples
T1.0–T1.4 TCPRoute: control, 75/25 band, mirrored weight-0 drain, all-drained floor, delete unchanged (#879)
T2.0 no TLSRoute → all three SNIs reach the FLOOR 60
T2.1 SNI alpha.l4tls.test → l4tls-a 20
T2.2 SNI bravo.l4tls.test → l4tls-b 20
T2.3 SNI nomatch.l4tls.test → the FLOOR, while the other two still reach their own backends 20 + 10 + 10
T2.4 both TLSRoutes deleted → every SNI back to the FLOOR 40
T3.0 no UDPRoute → no datagram answered 10
T3.1 UDPRoute 100/0 → every datagram answered by l4udp-a, none by the weight-0 backend 40
T3.2 UDPRoute deleted → no datagram answered again 10

⚠️ Not executed against a cluster

This has not been run — not on kind, not on talos-main. The parent session owns cluster access and will run it there. Everything that was verified is listed under "Evidence" below; I am not claiming a green run I did not have.

The UDP leg in particular has never been exercised anywhere: the UDP data path was parked on 2026-07-02 and has only ever been touched as control-plane config since. If the first real run shows the reply path does not survive kind, the honest outcome is to file that as its own issue and cut T3 back to what //test/envoy_validate already gates (#876) — not to mark it skipped. A skipped test that looks like coverage is worse than a documented gap.

Why the TLS probes dial a port nothing binds

This is the one non-obvious design decision, and it is load-bearing.

BuildCaptureTLSRouteFilterChains matches prefix_ranges: <ClusterIP>/32 + server_names and no destination_port. Proposal 037 then gave every TCP-primary service destination_port-qualified floor chains (:18082 and the service's own primary port) plus a portless any-port shim. Envoy resolves destination_port first and consults the portless bucket only when no chain claims the exact port — so a TLS dial to the primary port, or to :18082, lands on the port-qualified floor chain and the SNI chains are never considered.

So T2 dials 8443, which no chain claims. The surviving candidates are then exactly the portless ones: the SNI chains and 037's any-port shim. That is what makes "same client, same port, three SNIs, three different answers" a real comparison.

Two consequences are written into the script header rather than left to be rediscovered, and are filed as #911: TLSRoute is reachable today only through a shim that 037 Phase 4 proposes to remove (and TLSRoute traffic increments the very counter Phase 4's removal is gated on); and if the SNI chains are ever port-qualified, T2's dial port has to move with them — at which point this suite goes red and says so, which is the point.

UDP: delivery only, and why that is not a cop-out

#868's own scope note rules UDP selection out: the per-pod udp_proxy carries a bare single-cluster RouteSpecifier, so a "UDPRoute picks the right backend" test would fail by design rather than find a bug. That is #873, being fixed in parallel; this PR touches neither common/l4project/ nor agent/internal/l4route/.

T3.1 still asserts a weight, because there is exactly one weight shape both implementations must agree on:

A single udpbravo therefore fails under both, and the assertion survives #873's fix unchanged. The mirror (0/100) is deliberately absent: that one is the #873 case, and adding it would mean landing a test that must stay red until an unrelated PR merges.

UDP rides the mesh in plaintext — mTLS is a TCP/TLS construct, there is no DTLS, and the udp: clusters carry no transport socket at all. Nothing here expects or asserts mTLS on that leg, and the header states that a passing T3 is not evidence of an authenticated UDP path.

Sample counts, and why they separate the cases

The TCP leg's 200-probe band (#879) is unchanged; its sampling maths is in the script.

TLS is not sampled statistically at all. Filter-chain selection is deterministic — a match, not a load-balancing draw — so each phase asserts exhaustively: 20/20 for that SNI's marker and zero of anything else. One stray answer is a defect, not noise. The collapse bug this is meant to catch (SNI ignored, chain 0 always wins) shows up as tlsalpha answering the bravo probe, i.e. on the first sample; 200 probes would buy nothing but runtime.

UDP: 40 datagrams, also exhaustive (40 udpalpha, 0 udpbravo, 0 NOREPLY, 0 other) — again not a per-datagram draw under either implementation. 40 rather than 10 because the interesting non-deterministic failure here is a lossy path: nc -u -w 1 makes each probe cost about a second, and a path dropping 5% of datagrams slips past a 10-sample run about 60% of the time but past a 40-sample run only about 13% of the time. 40 fits comfortably in the job's 60-minute budget.

Evidence

The shellcheck gate covers the new file (the #853 check)

e2e/l4routes.sh is in //e2e:e2e_shell. Proof that the gate can actually fail on these lines — canary inserted at line 1057, inside the new verify_tls_control:

$ bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //e2e/...
ERROR: .../e2e/BUILD.bazel:17:11: Linting //e2e:e2e_shell with ShellCheck failed: (Exit 1)

In e2e/l4routes.sh line 1057:
	local shellcheck_canary="$(svc_vip l4tls-front)"
              ^---------------^ SC2034 (warning): shellcheck_canary appears unused. Verify use (or export if used externally).
              ^---------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
ERROR: Build did NOT complete successfully

Canary removed, file byte-identical to before it was inserted:

$ bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //e2e/...
INFO: Found 27 targets...
INFO: Build completed successfully, 2 total actions

bash -n e2e/l4routes.sh clean. bazel run //:format.check reports no finding on this file.

Manifests validated offline against the real CRDs

The heredocs were rendered with kc stubbed out, parsed as YAML, and checked against the gateway-api v1.6.2 experimental schemas:

  • tlsroutes, udproutes and tcproutes all serve v1 with storage: true — which the agent's crdcheck requires (it is v1-only, with no v1alpha2 fallback), and which install_gwapi_crds now gates on for all three rather than only TCPRoute.
  • TLSRoute.spec requires hostnames, and spec.rules carries maxItems: 1 — which is why two TLSRoute objects are needed rather than one route with two rules. UDPRoute has the same maxItems: 1.
  • Both carry the Must have port for Service reference CEL rule on backendRefs; every backendRef here sets port.
  • The three SNI names match the Hostname pattern.
  • parentRefs sets group: "" explicitly — the CRD default is gateway.networking.k8s.io, and the reconciler skips any parentRef whose group is non-empty.

Falsifiability: what observed value makes each assertion fail

assertion fails when the probe observes
T2.0 require_crd TLSRoute tlsroutes CRD absent or not served at v1 — hard die, not a skip (see below)
T2.0 VIP lookup l4tls-front has no registrar-generated mesh Service → empty ClusterIP
T2.0 all three SNIs any of the 60 answers is tlsalpha/tlsbravo (SNI routing with no route applied) or NOREPLY (the TLS floor is not carrying traffic, or the handshake never completed)
T2.1 any of 20 is tlsfloor (the SNI chain lost the match — the port-shadowing case, #911), tlsbravo (wrong backend), or NOREPLY
T2.2 as T2.1, mirrored. This is what catches "chain 0 always wins", which T2.1 alone would not
T2.3 unmatched SNI tlsalpha/tlsbravo (a chain matched a name it does not carry) or NOREPLY (the connection was dropped instead of falling through)
T2.3 re-assert tlsfloor on alpha/bravo — i.e. both routes had silently stopped matching, which would otherwise read as a passing fall-through
T2.4 any answer that is not tlsfloor after both routes are deleted (chains outlived their routes)
T3.0 any datagram answered before a UDPRoute exists (a listener outlived its routes, or something outside the mesh serves that VIP)
T3.1 convergence NOREPLY — the CNI's nftables UDP REDIRECT, udp_proxy's receive on the redirected socket, or conntrack un-DNATing the reply. The die message names all three and points at the UDPRoute input discarded log line first, because a discarded backend is a different failure from a broken data path
T3.1 none == 0 any unanswered datagram once delivery works — a lossy path, which is a distinct defect from an absent one
T3.1 bravo == 0 one datagram reaching the weight-0 backend (#492's shape, under either implementation)
T3.1 other == 0 udpfloor or an unknown marker — there is no UDP floor today, so observing one is itself a finding
T3.2 any answer still arriving 180s after the UDPRoute is deleted

The weak one, stated rather than hidden: T3.0's NOREPLY has two possible causes the probe cannot separate — redirect-to-nothing (the documented behaviour: "no UDPRoute = no listener = datagrams discarded"), or no redirect at all plus a mesh Service with no UDP port. It can still fail, so it is kept, but T3.1 does not rest on it.

No assertion in the new legs is unfalsifiable: there is no || true on a check, and nothing is gated behind an env var that CI does not set.

Deliberate deviation: a missing CRD fails here, it does not skip

A missing Gateway API CRD normally deserves a clean skip. Not in this harness: up installs all three CRDs itself, so their absence means a broken environment, and a leg that skips itself green in a suite whose whole job is catching silent L4 regressions is precisely the #853 defect. install_gwapi_crds now gates on all three being Established and served at v1, and require_crd dies with a message telling you to run up first.

Fixture changes

All l4echo workloads (including the pre-existing TCP ones) now carry runAsNonRoot + seccompProfile: RuntimeDefault at pod level and allowPrivilegeEscalation: false, readOnlyRootFilesystem: true, capabilities: drop [ALL] at container level. The image is already distroless/static running as uid 65532 (asserted by //e2e/l4echo's container test) and writes nothing to disk — the TLS cert is minted in memory at start-up — so this states what was already true rather than changing it.

The client declares all nine services in config.aether.io/upstreams. That is not an optimisation for L4: tcp_proxy and udp_proxy have no ODCDS cold path, so an undeclared upstream produces a chain that matches and a cluster that does not exist, which looks exactly like a routing bug.

Nightly wiring

The l4-routes job already exists and already feeds report-failure, whose missing GH_REPO (#868's sibling finding) was fixed earlier — so nothing added here can fail silently. Changed: the verify step's name, and the diagnostics now capture tlsroutes/udproutes, the TLS and UDP parents' logs, and a grep of the agent log for UDPRoute input discarded, so a discarded backend (#873/#874) is distinguishable from a broken data path at triage time.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

The kind L4 harness has covered TCPRoute since #879. This adds the two
remaining legs, which is the rest of #868's acceptance.

TLSRoute (T2.0-T2.4). The parent and both backends now speak TLS, so
#868's corrected fall-through criterion can be asserted POSITIVELY: a
third, unmatched SNI must reach the FLOOR backend by name, not merely
fail to reach A or B (an absence is also satisfied by a dropped
connection). SNI selection is asserted in both directions, because a
one-way assertion stays green if the SNI chains are ignored entirely and
chain 0 always wins.

The probes dial a port NO filter chain claims, and that is load-bearing.
BuildCaptureTLSRouteFilterChains matches ClusterIP/32 + server_names with
no destination_port; proposal 037 then gave every TCP-primary service
destination_port-qualified floor chains for :18082 and its own primary
port. Envoy resolves destination_port first and consults the portless
bucket only when no chain claims the exact port, so a TLS dial to either
of those ports lands on the floor and the SNI chains are never
considered. Dialing an unclaimed port leaves exactly the portless
candidates -- the SNI chains and 037's any-port shim -- which is what
makes T2.1/T2.2 and T2.3 a real comparison. Two consequences are stated
in the header rather than left to be rediscovered: TLSRoute is reachable
today only through a shim 037 Phase 4 proposes to remove, and
port-qualifying the SNI chains would move this dial port.

UDPRoute (T3.0-T3.2). Delivery only, per #868's scope note: the per-pod
udp_proxy carries a bare single-cluster RouteSpecifier, so asserting
backend selection would fail by design rather than find a bug (#873).
The 100/0 shape T3.1 uses is the one shape both implementations must
agree on -- today's path takes backends[0] and a weight-honouring one
must DRAIN the weight-0 backend (#492) -- so the assertion survives
#873's fix unchanged. The mirror is deliberately absent: it IS the #873
case. UDP rides the mesh in plaintext and the header says so; a passing
T3 is not evidence of an authenticated UDP path.

Every leg keeps the suite's negative controls, so each probe re-proves
its own discriminating power on every run rather than once at review
time (#853): three `floor` states for TCP, three for TLS, and two
`unanswered` states for UDP.

A missing CRD is a hard failure here rather than a clean skip. `up`
installs all three and now gates on all three being served at v1; a leg
that skips itself green cannot fail, which is the defect this suite
exists to avoid.

NOT EXECUTED AGAINST A CLUSTER. bash -n and the shellcheck gate are
green, the rendered manifests were validated against the gateway-api
v1.6.2 CRD schemas offline, and the chain-selection reasoning above is
read from the generators -- but no run has happened. The UDP data path
in particular has never been exercised anywhere (parked 2026-07-02), so
T3 is the leg most likely to be red first.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo force-pushed the feat/868-l4-route-e2e branch from a9c7c88 to e7724b0 Compare September 23, 2026 10:20
@bpalermo
bpalermo enabled auto-merge (squash) September 23, 2026 10:39
@bpalermo
bpalermo merged commit 6f2043b into main Sep 23, 2026
22 checks passed
@bpalermo
bpalermo deleted the feat/868-l4-route-e2e branch September 23, 2026 10:53
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.

no end-to-end coverage for L4 routes (TCPRoute / TLSRoute / UDPRoute)

1 participant