Repository navigation
test(envoy-validate): gate the three L4 listener shapes on every PR (#868) - #876
Merged
Merged
Conversation
…868) L4 routing (proposal 018 Phase 3b) is shipped, default-on and unconditional, and the only thing standing behind it is unit tests of the projector. This is PR1 of #868: the cheap half, so the config shapes are gated on every PR rather than once a night (scripts/ci-impacted-targets.sh classifies //test/envoy_validate as a unit target). Three bootstraps now go through the pinned production Envoy in --mode validate: - capture_tcproute_bootstrap.json weighted_clusters tcp_proxy on the floor chain, two backends 75/25 - capture_tlsroute_bootstrap.json two per-SNI chains matching <VIP>/32 + server_names, ALONGSIDE the floor chain matching the same /32 with no server_names - capture_udp_bootstrap.json connection-less udp_proxy listener plus the plaintext STATIC "udp:" cluster Envoy's opinion is the point for two of these. Dropping the SNI match makes it reject the TLS listener outright ("filter chain ... has the same matching rules defined as ..."), and moving the udp_proxy config into a filter chain makes it reject the UDP one ("1 filter chain(s) specified for connection-less UDP listener") -- a rule l4route.go records in a comment and nothing enforced until now. So it is Envoy, not a Go assertion, that certifies the SNI chains and the floor chain can share a listener. That coexistence IS the fall-through #868 asks about: a non-matching SNI reaching the floor is designed behaviour, since Envoy selects chains by specificity, so it is asserted positively rather than assumed away. The issue's original wording had this backwards. Validation is fail-open about everything it has no opinion on, though, and it is entirely satisfied by a fixture that stopped emitting the thing under test. So each leg also gets a structural assertion over the serialised bytes: the weights survive, a drained backend (weight 0) collapses the proxy to the single-cluster form rather than being normalised to an equal share (#492), every weighted cluster is actually defined (tcp_proxy has no on-demand CDS), the UDP listener carries zero filter_chains and binds UDP in the pod netns, and the "udp:" cluster has no transport socket and dials the backend's APPLICATION port. Every assertion was seen red once, by reverting the production hunk it guards where one exists -- including the pre-#492 `weight 0 -> 1` normalisation, which this reproduces as "bravo still present at weight 1". Two of the first drafts could NOT fail: they compared the generated weights and the capture port against the same constants the fixture was built from. Both now assert independent literals, with the measurement in a comment, because that is the aether#853 shape appearing inside the test written to avoid it. UDP scope is delivery only. GenerateUDPCaptureListener takes a bare Cluster from the first backend of the first sorted service, so backend selection is not expressible (#873); no assertion pretends otherwise. Test-only: no charts/ change, so no Chart.yaml bump. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR1 of #868. Adds
//test/envoy_validatecoverage for the three L4 listener shapes so they gate every PR as unit targets, rather than waiting on the nightly kind harness (PRs 2–4). Test-only: nocharts/change, so noChart.yamlbump. No production code touched.What is covered
Three new bootstraps go through the pinned production Envoy in
--mode validate:capture_tcproute_bootstrap.jsonweighted_clusterstcp_proxyover two backends, 75/25capture_tlsroute_bootstrap.jsonprefix_ranges <VIP>/32plusserver_names, on the same listener as the floor chain matching the same/32with noserver_namescapture_udp_bootstrap.jsoncapture_udp_<pod>listener withudp_proxyas a listener filter and nofilter_chains, plus the plaintext STATICudp:clusterEnvoy's opinion is the point for two of them. Dropping the SNI match makes it reject the TLS listener outright; moving the
udp_proxyconfig into a filter chain makes it reject the UDP one. So it is Envoy — not a Go assertion — that certifies the SNI chains and the floor chain can share a listener.That coexistence is the fall-through #868 asks about. The acceptance list was first written as "a non-matching SNI does not fall through to a default", and the correction on the issue is right: Envoy selects filter chains by specificity, so a chain with no
server_namesis a wildcard on SNI and a non-matching SNI lands on the floor by design. This PR asserts that positively — the floor chain exists, shares the/32, sets noserver_names, and routes to the parent's own cluster rather than to either TLSRoute backend.Validation is fail-open about everything it has no opinion on, and is entirely satisfied by a fixture that stopped emitting the thing under test. So each leg also gets a structural assertion over the serialised bytes:
TestCaptureTCPRouteWeightedFloorChain— the floor really carriesweighted_clusters, at the weights the route asked for, and every weighted cluster is defined by the bootstrap (tcp_proxyhas no on-demand CDS: an undefined backend gives a chain that matches and then has nowhere to send the connection).TestCaptureTCPRouteDrainCollapsesToSingleCluster— the fix(l4route): honor weight:0 as drain, don't normalize to 1 #492 property at the config layer: an explicitweight: 0backend is absent, so the proxy collapses to the single-cluster form.TestCaptureTLSRouteSNIChainsCoexistWithFloor— one hostname per chain, each scoped to the/32; both SNIs routed, to different backends (a one-SNI assertion passes even ifserver_namesis ignored and chain 0 always wins); the floor unconstrained on SNI and pointed at the parent.TestCaptureUDPListenerIsConnectionless— zerofilter_chains, binds UDP in the pod netns on the capture port,udp_proxypresent and naming a defined cluster.TestCaptureUDPClusterIsPlaintextAtTheAppPort— the concrete shape of "UDP rides the mesh in plaintext": STATIC, inline load assignment, no transport socket, endpoints rewritten toprotocol: UDPat the backend's application port. Per the plan this lives here rather than as a wire-level check in the shell harness.Two assertions that could not fail — found and fixed
Before the red runs below, two of the first-draft assertions were vacuous: they compared the generated weights, and the UDP listener's port, against the same constants the fixture was built from.
Measured: editing
L4TCPWeightAfrom75to50left the test GREEN.Both now assert independent literals, with that measurement recorded in a comment next to them. This is the aether#853 shape appearing inside the test written to avoid aether#853, which is exactly why the issue asks for the red run rather than for a passing test.
Red-run evidence
Every assertion was seen red once — by reverting the production hunk it guards where one exists. Breaks were applied in a throwaway
git worktree, never in the shared checkout.(a) Revert the #492 fix — restore
if b.Weight == 0 { b.Weight = 1 }inl4RulesToWeightedClusters. This reproduces the bug that actually shipped:(b) Drop
ServerNamesfromBuildCaptureTLSRouteFilterChains— Envoy itself rejects the listener:(c) Constrain the floor chain on SNI (
ServerNames: ["floor.invalid"]inbuildCaptureTCPFloorFilterChain):(d) Put
udp_proxyin a filter chain instead oflistener_filters— Envoy rejects it, with the exact messagel4route.goonly had in a comment:(e) Stop rewriting the endpoint port in
UDPLoadAssignment:(f) Weights (the fixed, non-vacuous form) —
L4TCPWeightA75 → 50:(g) Remove a weighted backend's cluster from the bootstrap:
(h) Point both SNI chains at the same backend (the mirror assertion):
(i) Give the
udp:cluster a transport socket — the Go assertion fires, and--mode validatesegfaults (the documented STATIC-cluster-with-SDS-over-adsvalidation-server bug thatrewriteSDSToExplicitSourcealready works around, so validation alone would not have been a usable signal here):(j) / (k) Widen the SNI chain match to
/24, then dropprefix_rangesentirely:(l)–(q), the remainder — one backend only (
tcp_proxy has cluster_specifier *TcpProxy_Cluster, want weighted_clusters); drain the other backend (tcp_proxy cluster = "tcp:l4-front...", want "tcp:l4-a..." — the surviving backend); floor pointed at a TLSRoute backend (floor chain routes to "tcp:l4-tls-a...", the backend of SNI "a.l4.test" — a non-matching SNI would reach a TLSRoute backend); UDP listener binds TCP (binds protocol TCP, want UDP, and--mode validatealso exits 1); endpoint protocol left TCP (endpoint 10.244.3.7 protocol = TCP, want UDP); cluster type changed to STRICT_DNS (type = STRICT_DNS, want STATIC with an inline load assignment).What I judged not worth asserting
GenerateUDPCaptureListenertakes a bareClusterfrombackends[0]of the lexicographically first service key, so weights are discarded and a second UDPRoute-backed service on the node has no effect. Any selection assertion would fail by design; that is UDPRoute ignores backend weights and collapses multiple services onto one cluster #873, and this PR's UDP scope is delivery shape only.backendRef.porton an L4 route. It is ignored — thetcp:/udp:cluster's endpoints already carry the port — so asserting on it would pin something that carries no meaning.prefix_rangesas a separate red run. It goes through the sameassertMatchesParentIPhelper that breaks (j)/(k) drove red on the SNI chains.TestCaptureUDPClusterIsPlaintextAtTheAppPort); in the shell harness it would be decoration.Verification
Envoy really runs over the three new bootstraps (
--test_arg=-test.v):Refs #868. Next: PRs 2–4 (the
e2e/l4routes.shkind harness), in progress separately.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr