Repository navigation
fix(agent): redirect-all passthrough must never shadow a known mesh target (MESH-HTTP RDS-reload race) - #432
Merged
Conversation
…arget 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. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S
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.
The race
The MESH-HTTP feature tests (
MeshHTTPRouteRequestHeaderModifier/MeshFrontend/RedirectHostAndStatus/Weight) flake: the modifier applies hundreds of times in-suite but never hitsRequiredConsecutiveSuccesses=3consecutively. This is not config generation (proven correct by #423/#424/#430 and stable-config curl). It is an RDS-reload convergence race under the conformance suite's own cross-test apply/delete churn.Mechanism. A GAMMA HTTPRoute add/delete makes the gamma reconciler re-list and re-
SetServiceRoutesbetween two reconciles. In the delete→create gap, a route target'sserviceRoutesentry is momentarily empty → its dedicatedcap_httpvhost is absent from the rebuilt RouteConfiguration. Envoy's per-RouteConfiguration RDS apply is atomic, so the leak means 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 topassthrough_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.The 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
:authoritysafe_regexroute per in-scope mesh authority (every non-mesh cluster.local spelling — bare name,<name>.<ns>,<name>.<ns>.svc, FQDN — with an optional:port), pinning it to its mesh cluster before the passthrough fallthrough.Crucially, the set is derived from the stable signals —
captureAuthorities(fed by the generated mesh Services, untouched by HTTPRoute churn) plus current route targets — and not the demand-scoped dependency set, whose route-target membership churns with the rule and would re-introduce the race. So a known service's captured traffic 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 (a silent 200 that drops the GAMMA feature). The dedicated vhost still wins on host-match precedence when present and carries the GAMMA filters; this is the floor under it.Scope: redirect-all capture only (no passthrough ⇒ nothing to shadow ⇒ catch-all keeps its hard 404). GATEWAY-HTTP (edge, 43/0 hard gate) and production mTLS paths are untouched. SPIRE-off / redirect-all guards on the new behavior.
Validation
//agent/internal/xds/proxy:proxy_test— a known target resolves to its cluster under every spelling + port, never the passthrough; foreign and mesh-shaped authorities unaffected; known-target routes only emitted in redirect-all.//agent/internal/xds/cache:cache_test—captureKnownTargetssurvives a simulated GAMMA-rule-clear churn even as the dedicated vhost vanishes (the race window), covering the SA-backed MeshFrontend shape and the versioned-fanout route-only shape.//test/envoy_validate—envoy --mode validateaccepts the new:authoritysafe_regex route shape in the cap_http RouteConfiguration.//agent/...unit suite green.Honesty on the kind proof
The full MESH-HTTP suite is the CI
mesh-httpjob (soft / continue-on-error). It cannot beworkflow_dispatch-ed from a non-default branch, and the local kind path is a heavyweight multi-image build + cloud-provider-kind stand-up. This PR ships the offline proof (unit tests that reproduce the race window and assert the invariant +envoy --mode validate). Run themesh-httpjob once this is onmainto confirm the per-test score moves; the data path was already proven correct by curl, so this targets exactly the convergence artifact that gated the consecutive-success counter.🤖 Generated with Claude Code