Repository navigation
fix(mesh): MeshFrontend — host-match short names for SA-backed GAMMA route targets - #423
Merged
Merged
Conversation
…route targets MESH-HTTP MeshFrontend failed in CI because an SA-backed mesh Service that is ALSO a GAMMA route target (an HTTPRoute parentRef'd to a Service that is its own backend, e.g. "echo-v2" with a ResponseHeaderModifier filter) only emitted its cluster.local FQDN + mesh :18081 cap_http domain spellings — never the short names a client actually dials. MeshFrontend's client (echo-v1) dials `Host: echo-v2` (bare same-namespace name, port 80 implied). The captured request's :authority is "echo-v2", which did not host-match the route-target vhost (it carried only echo-v2.<ns>.svc.cluster.local[:18081] and echo-v2.<ns>.aether.internal[:18081]). The dial fell through to passthrough_original_dst, so the GAMMA ResponseHeaderModifier (X-Header-Set: set) was never applied → the test's "Send to service" case failed on the missing response header. This only affected the route-target-IS-its-own-backend shape (captureVhosts' first loop, SA-backed authorities). The versioned-fanout shape (a route target with no own SA — captureVhosts' second loop) already emitted all short-name + real-port spellings, which is why the agent's minimal local repro (which used that shape) passed while CI (which uses echo-v2) failed. Fix: extract the route-target domain-spelling logic (short names <name>.<ns>, <name>.<ns>.svc, the guarded bare name, and real Service ports — proposal 023 M2) into routeTargetDomains and apply it in the first loop too, but only when the authority carries GAMMA rules. Plain mesh Services (no rules) keep their minimal spellings: passthrough reaches the same backend and emitting bare short names for every service would risk cross-namespace bare-name NACK collisions. Reproduced and locked with a unit test (TestCaptureVhosts_SABackedRouteTargetShortNames) that fails on the old code (missing "echo-v2"/"echo-v2:80" domains) and passes now. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S
bpalermo
added a commit
that referenced
this pull request
Jun 29, 2026
…arget (#432) The MESH-HTTP feature tests (RequestHeaderModifier / MeshFrontend / Redirect / Weight) flaked: the modifier applied 271x in-suite but never hit RequiredConsecutiveSuccesses=3 in a row. Root cause is an RDS-reload convergence race under the conformance suite's own cross-test apply/delete churn — NOT config generation (proven correct by #423/#424/#430 + stable-config curl). Mechanism: a GAMMA HTTPRoute add/delete makes the gamma reconciler re-list and re-`SetServiceRoutes` between two reconciles. In the delete→create gap the route target's `serviceRoutes` entry is momentarily empty, so its dedicated cap_http vhost is absent. Envoy's per-RouteConfiguration RDS apply is atomic, so the leak implies the PUSHED table was itself missing the vhost: an in-flight captured request to that KNOWN target then lands on the redirect-all catch-all (domain "*") and falls to `passthrough_original_dst` → kube-proxy → the GAMMA filters are silently skipped ("got some-other-value"), resetting the consecutive-success counter. Not reproducible manually (the stable-config curl always runs between rebuilds); only under the suite's rapid churn. Fix (direction 2, the robust invariant): the passthrough must never shadow a service the mesh knows about. The redirect-all catch-all now carries a known-target safety net — one `:authority` safe_regex route per in-scope mesh authority (all non-mesh cluster.local spellings, any port), pinning it to its mesh cluster BEFORE the passthrough fallthrough. The set is derived from the STABLE signals (captureAuthorities, fed by the generated mesh Services and untouched by HTTPRoute churn, plus current route targets) — deliberately NOT the demand-scoped dependency set, whose route-target membership churns with the rule and would re-introduce the race. A known service's captured traffic therefore fails CLOSED into the mesh (a brief 503 if the demand-scoped cluster is momentarily absent, which the harness cleanly retries) instead of OPEN to kube-proxy. The dedicated vhost still wins on host-match precedence when present and carries the GAMMA filters; this is the floor. Scope: redirect-all capture only (no passthrough ⇒ nothing to shadow ⇒ catch-all keeps its hard 404). GATEWAY-HTTP (edge) and production mTLS paths untouched. Tests: proxy-level (a known target resolves to its cluster under every spelling + port, never the passthrough; foreign/mesh-shaped authorities unaffected; gated on redirect-all), cache-level (the safety net survives a simulated GAMMA-rule-clear churn even as the dedicated vhost vanishes), and `envoy --mode validate` accepts the new route shape. Claude-Session: https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S Co-authored-by: Claude Opus 4.8 <[email protected]>
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.
Summary
MESH-HTTP conformance MeshFrontend failed in CI (passed in the agent's minimal local repro). Root-caused to a real cap_http host-matching gap, fixed minimally.
The bug (with evidence)
MeshFrontend(upstream test) is not cross-namespace (the task's initial hypothesis): both client (echo-v1) and target (echo-v2) live ingateway-conformance-mesh. Its HTTPRoutemesh-split-v1hasparentRef: Service echo-v2with a ResponseHeaderModifier filter (X-Header-Set: set), backendRefecho-v2:80. Case 1 ("Send to service"):echo-v1execsclient http://echo-v2/→ expects 200 +X-Header-Set: set.The client dials the bare name
echo-v2(port 80 implied), so the captured request's:authorityisecho-v2. Butecho-v2is an SA-backed mesh Service that is also its own GAMMA route target → it was handled bycaptureVhosts' first loop, which only emitted:echo-v2/echo-v2:80/echo-v2.<ns>/echo-v2.<ns>.svcwere never emitted → the dial missed the route-target vhost → fell through topassthrough_original_dst→ the GAMMA ResponseHeaderModifier was never applied → noX-Header-Set→ MeshFrontend case 1 fails. (Case 2, "Send to pod IP", expects the header to be absent and passes regardless.)The versioned-fanout shape (a route target with no own SA, e.g. an
echotarget →echo-v1/echo-v2) goes through the second loop, which already emits every short-name + real-port spelling — which is exactly why the agent's minimal repro (that shape) passed while CI (echo-v2, its own backend) failed. Not an env/timing artifact.The fix
Extract the route-target domain-spelling logic (short names + guarded bare name + real Service ports, proposal 023 M2) into
routeTargetDomains, and apply it in the first loop too — only when the authority carries GAMMA rules. Plain mesh Services (no rules) keep their minimal cluster.local + mesh spellings (passthrough reaches the same backend; emitting bare short names for every service would risk cross-namespace bare-name NACK collisions). Strictly additive, production-safe; the second loop's behavior is byte-for-byte preserved.Proof
TestCaptureVhosts_SABackedRouteTargetShortNamesreproduces the exact MeshFrontend shape. On the old code it fails with the observed missing-domain set; with the fix the vhost carriesecho-v2,echo-v2:80,echo-v2.<ns>,echo-v2.<ns>.svc, and the GAMMA rule routes to the backend cluster. Full//agent/internal/xds/cache,proxy,capture, andgammatest targets pass. (A full kind MESH e2e was not run here — ~3 image builds + CNI/agent; the unit test reproduces the exact host-match gap with the exact MeshFrontend domains.)🤖 Generated with Claude Code