Repository navigation
fix(agent): the destination reports each response's outcome in x-aether-outcome and the caller retries on that header alone, so a request the application had received is not replayed and an undelivered gRPC call is retried (#1641, #1646) - #1645
Merged
Merged
Conversation
…tion is no longer replayed on another endpoint unless its method is idempotent (#1641) Every caller-side route retries a 503 on another endpoint, for any method. A destination proxy answers 503 both when it never reached its application (UF, UH, UO, NC) and when it had already sent the request and the application's connection then closed or reset before a response (UC, UR, LR). The caller could not tell them apart, so a POST the application had received could be run a second time on another pod. The status code does not change. The destination's inbound connection manager now marks the second kind of 503, for a method that is not idempotent, with the response header x-envoy-ratelimited (local_reply_config: response flag UC/UR/LR and :method outside GET, HEAD, OPTIONS, TRACE, PUT, DELETE). That is the one response header Envoy's retry state reads as "do not retry", ahead of every status-code condition, so the caller's retry policy is unchanged and a caller of any version honours the mark. An unmarked 503 is retried as before: connect failures, no healthy upstream, an application's own 503, and every 503 of a destination that is not upgraded yet. An idempotent request that had begun is still retried on another endpoint, as before. The inbound route removes the header from what the application answered, so an application cannot set the mark itself. Every caller-side route to a mesh cluster (outbound, capture, GAMMA, on-demand, known targets, the edge's mesh backends) removes it from the response it forwards, so it reaches no client application and does not leave the mesh. The edge leaves the header of a cleartext Kubernetes Service backend alone. //agent/test/mtlspool TestBegunRequestIsNotReplayed runs the agent's outbound route table against the agent's inbound connection manager on the pinned proxy, with an application that closes, resets or aborts after reading the request, and checks by request URI that no POST or PATCH is read by two applications. docs: workload-requirements, getting-started and the runbook say what is and is not retried. The retry count they gave ("2 attempts") was the number of retries. Closes #1641 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…er-outcome and the caller retries on that header alone (#1641, #1646) Replaces the first form of this change (an x-envoy-ratelimited mark with the caller's status-code policy unchanged), on the owner's decision. Destination. Every inbound connection manager (mTLS TCP, cleartext, HTTP/3) stamps x-aether-outcome on every response from its virtual host, overwriting what the application set: <code>;<flags>;<method>;<details> %RESPONSE_CODE%;%RESPONSE_FLAGS%;%REQ(:METHOD)%;%RESPONSE_CODE_DETAILS% code is the application's status, or 0 for a reply the proxy generated (that is what Envoy holds when response headers are finalised). The local-reply mapper and the removal of x-envoy-ratelimited are gone: an application that sets that header gets Envoy's default again (never retried, header forwarded). Caller. outboundRetryPolicy is now connect-failure,refused-stream,reset-before-request,retriable-headers with one matcher on that header and no status-code condition. It matches an application's 503; a local reply for a request that never began (UF, UH, UO, NC); one for a request that had begun (UC, UR, LR) when the method is idempotent; and one for a stream the application refused (REFUSED_STREAM), for any method. Nothing else: no 200, no other application status, no begun POST, no flag the rule does not know, no response without the header. The regex is spelled to fit Envoy's limit of 100 RE2 instructions (a plain spelling compiles to 233 and the proxy rejects the route table). gRPC (#1646). A destination's own failure reaches a gRPC caller as HTTP 200 with grpc-status 14; the header is the same as for HTTP, so a call the destination could not deliver is now retried and one the application had received is not. Edge. A route to a mesh backend takes the header policy and removes the header; a route whose backends are all cleartext Kubernetes Services has no destination proxy to stamp one and keeps the status-code policy (nonMeshRetryPolicy); a rule that splits between the two takes the mesh one. Mixed versions are not worked around: an upgraded caller retries nothing a not-yet-upgraded destination answers, for the length of the agent roll. The runbook says what that looks like and how to keep it harmless. //agent/test/mtlspool TestBegunRequestIsNotReplayed now runs the production outbound listener's connection manager and route table against production inbound listeners, cleartext and mTLS, with HTTP/1.1 and h2c applications that close, half-close, reset, abort or refuse, a gRPC exchange, forged response and request headers, and both mixed-version pairings. Closes #1641 Closes #1646 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…ller retries, and a request header named x-aether-outcome is removed wherever a request enters the mesh (#1641) Two regressions the second adversarial review of this pull request proved. Overload. The connection manager's "503 envoy overloaded" (stop_accepting_requests) is written before the filter chain exists. Measured on the pinned proxy it reaches a caller either stamped by the inbound virtual host as "0;-;<method>;overload" (over the mesh's HTTP/2 hop) or with no header (a plain client). Neither matched the caller's rule, so a request no application had seen was no longer moved to another endpoint, which the chart's overload ladder promises. Now: - the inbound connection manager has a local-reply mapper that stamps x-aether-outcome on a local reply that has none, with the reply's own status as the code (%RESP(:STATUS)%; %RESPONSE_CODE% is 0 or the status there, depending on how the reply was generated). The overload reply becomes "503;-;<method>;overload", which the rule's first alternative already accepts; any other reply of that kind (400, 408, 431) gets a value no alternative matches; - the rule accepts "0;-;…overload" as well. The regex stays one matcher under Envoy's 100-instruction limit; the refused-stream literal is shortened to "e_refu" to make room. Request header. An edge rule that splits between a mesh service and a cleartext Kubernetes Service carries the mesh retry policy (Envoy has one retry policy per route, none per weighted cluster), and nothing overwrites the header on the cleartext share: a backend that echoes request headers let an external client make the edge replay its own POST. Every forwarding route of the edge, every caller-side route to a mesh cluster and the inbound virtual host now remove a request header of that name. Tests, adopted from the review: TestOverloadedDestinationIsShedToAnotherEndpoint, TestEdgeClientCannotDriveARetryThroughACleartextBackend (through the edge's own listener builder) and TestGRPCCallsWithARealClientAndServer (grpc-go on both ends; no new module requirement). Both regressions seen red on the previous head. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Oct 10, 2026
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.
Closes #1641
Closes #1646
Breaking for the length of an agent roll: see "Mixed versions" below.
What was wrong
Every caller-side route retried a
503on another endpoint, for any method. A destination proxy answers503both when it never reached its application and when it had already sent the request and the application's connection then closed or reset before a response. The caller could not tell them apart, so aPOSTan application had received could be run a second time on another pod (#1641). For gRPC it was wrong the other way round: both kinds reach the caller as HTTP200withgrpc-status: 14, and neither was retried (#1646).What is true now
The destination says what happened; the caller retries on that and on nothing else about the response. Status codes are unchanged.
Destination. Every inbound connection manager (mTLS TCP, cleartext, HTTP/3: one route builder) stamps
x-aether-outcomeon every response, overwriting anything the application set:codeis the application's status, or0for a reply the proxy generated itself (what Envoy holds when response headers are finalised; measured). The grammar is documented in one place,agent/internal/xds/proxy/outcome.go, and is a wire contract between agent versions; a unit test spells the header name and the format out so that neither changes by accident.Caller.
outboundRetryPolicy()isconnect-failure,refused-stream,reset-before-request,retriable-headerswith ONE matcher on that header.retriable-status-codesis gone, and a test guards that it,5xx,gateway-errorandresetnever come back. The regex:503;-;…: a503with no failure flag, any method: the application answering503itself, or the proxy answering before it chose a route;0;-;…overload: the proxy is overloaded (stop_accepting_requests), any method;0;<UF|UH|UO|NC>;…: a local reply for a request that never began, any method;0;<known flags>;<GET|HEAD|OPTIONS|TRACE|PUT|DELETE>;…: a request that had begun (UC,UR,LR), idempotent method;0;<known flags>;<method>;…e_refu…: the application refused the stream (remote_refused_stream_reset), any method.It is spelled this way because Envoy rejects a regex whose RE2 program exceeds 100 instructions, and the route table with it. A plain spelling of the same rule compiled to 233 on the pinned proxy; the field order, the shared prefixes,
U[FHO]and the ASCII classes bring it under. Two consequences, both tested: a flag set is(?:flag,?)+, which also accepts a set without commas or with a trailing one (Envoy's formatter is the only writer and never produces that), and a value containing non-ASCII fails closed. The rule fails closed on any flag it does not know.Why each flag:
UFconnect refused or timed out,UHno healthy host,UOcircuit breaker,NCapp cluster gone (teardown) are all "nothing sent". Left out on purpose:LH,DO,UDO,DF(the inbound route cannot produce them),NR(a 404 everywhere),RL/RLSE/UAEX(verdicts),FI,IH/DPE,OM(also resets requests in flight),URX. Begun but never replayed for any method:UT,DT,UPE,UMSDR.Removal. Every retrying route to a mesh cluster removes the header from the response it forwards (outbound, capture, GAMMA rules and catch-all, on-demand, known targets, edge). A request header of that name is removed wherever a request enters the mesh's hands: every forwarding route of the edge, every caller-side route to a mesh cluster, and the inbound virtual host before the application.
Replies without a route. A virtual host's headers apply only when a route was chosen. The inbound connection manager therefore also has a local-reply mapper that stamps the header on a local reply that has none (
ADD_IF_ABSENT), with the reply's own status as the code (%RESP(:STATUS)%). This is what keeps an overloaded proxy's503retriable; see the second review below.Edge. A route to a mesh backend takes the header policy. A route whose backends are all cleartext Kubernetes Services has no destination proxy to stamp a header and keeps the status-code policy (
nonMeshRetryPolicy): the edge is the last proxy before the application there, so a503response is the application's own. A rule that splits between the two takes the mesh policy, so its cleartext share loses the retry of an application's503. The east-west waypoint tunnel is raw TCP and sees no headers.x-envoy-ratelimited(the first form of this pull request used it as the mark): nothing sets or removes it now. An application that sends it on a503gets Envoy's default: not retried, header forwarded. A test pins that.Measured live
//agent/test/mtlspoolTestBegunRequestIsNotReplayed, on the proxy the chart pins on main (quay.io/aethermesh/proxy:7ae32088…, Envoy 1.40.0-dev 20261009.189f198). One Envoy: the production outbound listener's connection manager and route table in front of production inbound listeners, each service with the endpoint under test and a healthy one. "Replayed" means the same request URI was read by both applications.x-aether-outcomePOST/PATCH200;-;GET;via_upstream500;-;GET;via_upstream503;-;POST;via_upstreamx-aether-outcome: 503;-;GET;via_upstream200;-;GET;via_upstream…: 200;-;GET;via_upstream503;-;POST;via_upstream0;UF;POST;upstream_reset_before_response_started{remote_connection_failure|delayed_connect_error:_Connection_refused}0;UH;POST;no_healthy_upstream0;NC;POST;cluster_not_found0;UC;POST;upstream_reset_before_response_started{connection_termination}UC)UC)RST_STREAM(INTERNAL_ERROR)0;UR;POST;upstream_reset_before_response_started{remote_reset}RST_STREAM(REFUSED_STREAM)0;UR;POST;upstream_reset_before_response_started{remote_refused_stream_reset}grpc-status: 140;UF;POST;…grpc-status: 140;UC;POST;…x-aether-outcome,x-envoy-retry-on,x-envoy-max-retries,x-envoy-retriable-status-codes; application reads it and closes0;UC;POST;…x-envoy-ratelimitedThe client never sees
x-aether-outcomethrough this release's caller. The gRPC exchange is a request withcontent-type: application/grpcanswered trailers-only by the proxy; the retried one lands on the healthy application.Second review: two regressions, fixed in
c1d17febOverload (F3). The connection manager's
503 envoy overloaded(stop_accepting_requests, the chart's overload ladder, on by default) is written before the filter chain exists. Measured: over the mesh's HTTP/2 hop it reaches a caller stamped by the virtual host as0;-;<method>;overload; a plain HTTP/1.1 or HTTP/2 client gets it with no header. Neither matched, so this release's caller left 6 of 12 requests at503(GETandPOST) where the previous caller moved all 12. Now the rule accepts0;-;…overload, and the mapper turns the unstamped shape into503;-;<method>;overload, which rule 1 accepts. Measured: 12 of 12200, both methods, each run exactly once by the healthy endpoint; the chart's comment is true again and is untouched. A malformed request, for comparison, is answered400with400;-;;http1.codec_error, which nothing matches.Client-driven edge retry (F4). On an edge rule that splits between a mesh service and a cleartext Kubernetes Service, an external client that sent
x-aether-outcome: 0;UF;POST;xto a cleartext backend that echoes request headers had itsPOSTexecuted 3 times. The edge now removes that request header on every forwarding route (and so do the caller's routes and the inbound). Measured through the edge's own listener builder: every request executed once. Envoy has one retry policy per route and none per weighted cluster, so the cleartext share of a mixed rule keeps the mesh policy; a cleartext backend that sets the header on its own response decides its own retry there, as it could by answering503.Also from that review: a real gRPC test (
grpc-goclient and server through both callers, unary and server-streaming; no new module requirement,make deps-auditclean); thehealthgateway.gocomment; a note that in a mesh without SPIRE the pod's single cleartext inbound chain also serves a source's TCP floor, whose HTTP clients then see the header (documented, not changed).stop_accepting_requestsgrpc-status: 14400;-;;http1.codec_error)stop_accepting_connectionsis the caller'sconnect-failure, as before)Mixed versions (measured, documented, not worked around)
POST /close503,GET /close503, application503503 (each200 x6, 503 x6over two endpoints). The caller's own conditions (connect failure to the destination pod, refused stream, reset before request) still apply.POST /closereplayed,503 UFretried; and the old caller forwardsx-aether-outcometo its client.The window is the agent rollout (and a rollback). The runbook ("Upgrading across #1641") says what an operator sees, that workloads should not be rolled while the agents roll, and that clusters exchanging traffic must be upgraded together.
The keep-alive race
Unchanged in mechanism, and the h1 app-cluster idle timeout is left as it is (Envoy's 1 h default). An application that closes an idle connection at the instant the proxy reuses it is a
UC. For idempotent methods the caller's retry hides it, as before. APOSTthat loses the race is a client-visible503now. The adversarial review of the first form measured 2 such503s in 3,600POSTs paced at the application's keep-alive timeout; my earlier harness, pacing 18–22 ms against a 20 ms timeout directly at the destination, saw 68UCin 1,500.Tests
x-envoy-ratelimited, both mixed-version pairings) and, in the first form, against main for the replay itself.agent/internal/xds/proxy/outcome_test.go: the regex against a table of about 100 values and against every Envoy response flag alone and in every pair, for an idempotent and a non-idempotent method, with and without the refused-stream detail (3,600 values on code 0 checked against a rule written without a regex, and the same sets on five real statuses, none of which may match); the stamp on every inbound connection manager; the policy and the removal on every retrying route; the edge's three cases; theretry_onguard.//agent/test/envoy_validate: two existing guards that list the retry conditions which cannot replay a sent request now acceptretriable-headers.//agent/internal/xds/...,//agent/test/...,//agent/...,//common/...,//test/harnesscontract/...,--config=raceon the four touched test targets, the lint build andmake format-checkpass locally. The live test: 12 stress runs, 0 failures.Not changed
No chart change, no harness-contract change, no new stat or access-log field. The header is removed on the caller's side before the response is logged, so the source row cannot carry it; the destination row already has the four fields it is made of. The runbook says how to join them.
Docs
docs/workload-requirements.md,docs/getting-started.md, and the runbook section with the upgrade note.An agent wrote this pull request.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr