Skip to content

fix(agent): redirect-all passthrough must never shadow a known mesh target (MESH-HTTP RDS-reload race) - #432

Merged
bpalermo merged 1 commit into
mainfrom
fix/mesh-http-passthrough-shadow-known-target
Jun 29, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/mesh-http-passthrough-shadow-known-target

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

The race

The MESH-HTTP feature tests (MeshHTTPRouteRequestHeaderModifier / MeshFrontend / RedirectHostAndStatus / Weight) flake: the modifier applies hundreds of times in-suite but never hits RequiredConsecutiveSuccesses=3 consecutively. 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-SetServiceRoutes between two reconciles. In the delete→create gap, a route target's serviceRoutes entry is momentarily empty → its dedicated cap_http vhost 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 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.

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 :authority safe_regex route 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 — captureKnownTargets survives 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 validate accepts the new :authority safe_regex route shape in the cap_http RouteConfiguration.
  • Full //agent/... unit suite green.

Honesty on the kind proof

The full MESH-HTTP suite is the CI mesh-http job (soft / continue-on-error). It cannot be workflow_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 the mesh-http job once this is on main to 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

…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
@bpalermo
bpalermo merged commit 5aa2f74 into main Jun 29, 2026
13 checks passed
@bpalermo
bpalermo deleted the fix/mesh-http-passthrough-shadow-known-target branch June 29, 2026 01:49
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