Repository navigation
fix(proxy): app-facing HTTP listeners keep idle connections for 1 hour, not the mesh inbound's 5 minutes (#1350) - #1358
Merged
Conversation
…r, not the mesh inbound's 5 minutes (#1350) One constant, downstreamIdleTimeout = 5m, set the downstream idle timeout of every HTTP connection manager. It was chosen for the mesh inbound, whose client is a peer proxy that idles its pools out at 30s. On the per-pod capture chain and the per-pod outbound listener the client is the application, and there the server's idle timeout has to exceed the client's: HTTP/1.1 has no GOAWAY, so a request written onto a kept-alive connection the proxy is closing at that instant is lost. buildHTTPConnectionManager now takes the idle timeout from its caller and has no default. The mesh inbound (TCP, QUIC, cleartext) keeps 5 minutes; capture_http and outbound_http get 1 hour, Envoy's default, stated. The edge's Phase 1 shared listeners, which inherited the same 5 minutes, take the 1 hour the per-Gateway edge listeners already had. Closes #1350 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
There was a problem hiding this comment.
🔵 Needs a closer look
Longer idle-connection retention remains unmeasured under workload churn and warrants human operational review.
0 open findings
What changed in this PR
Addresses #1350 by separating application-facing and peer-facing HTTP idle timeouts in Aether’s generated Envoy configuration.
Changes:
- Sets capture/outbound and shared edge listeners to 1 hour, preserving mesh inbound at 5 minutes.
- Requires explicit timeout selection and adds listener-level and generated-configuration regression tests.
- Documents reset diagnosis and connection-retention tradeoffs.
| File | Description |
|---|---|
| docs/runbook.md | Documents timeout behavior and operational checks. |
| agent/test/envoy_validate/idle_timeout_test.go | Checks timeouts across generated bootstraps. |
| agent/test/envoy_validate/builders.go | Extracts HTTP connection-manager idle timeouts. |
| agent/test/envoy_validate/BUILD.bazel | Registers the new validation test. |
| agent/internal/xds/proxy/networkfilter.go | Splits timeout constants and requires explicit selection. |
| agent/internal/xds/proxy/networkfilter_test.go | Updates shared-builder tests. |
| agent/internal/xds/proxy/ingress.go | Preserves peer-facing 5-minute timeouts. |
| agent/internal/xds/proxy/idletimeout_test.go | Tests timeout values across listener types. |
| agent/internal/xds/proxy/http3.go | Explicitly selects the edge timeout. |
| agent/internal/xds/proxy/filterchain.go | Sets outbound HTTP timeout to 1 hour. |
| agent/internal/xds/proxy/edge.go | Sets edge timeouts while preserving readiness behavior. |
| agent/internal/xds/proxy/capture.go | Sets capture HTTP timeout to 1 hour. |
| agent/internal/xds/proxy/BUILD.bazel | Registers listener timeout tests. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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 #1350
What was wrong
downstreamIdleTimeout = 5 * time.Minuteset the downstream idle timeout of every HTTP connection manager the agent generates. The value was chosen for the mesh inbound, whose client is a peer proxy that idles its pools out at 30 s. On the listeners where the client is the pod's application, the rule is the opposite one: the server's idle timeout must exceed the client's, because HTTP/1.1 has no GOAWAY. A request written onto a kept-alive connection the proxy is closing at that instant is lost, and a client that does not retry on a reused-connection failure sees a reset (1 request in 270,000 in the issue).What this changes
Option 1 of the issue.
buildHTTPConnectionManagerno longer has an idle timeout of its own: every caller passes one, so a new listener has to say who its downstream is. Two Go constants inagent/internal/xds/proxy/networkfilter.go, no chart value and no flag:peerFacingIdleTimeout = 5 * time.MinuteappFacingIdleTimeout = time.Hour(Envoy's default, now stated)Nothing under
charts/is touched.Every caller of
buildHTTPConnectionManagerbuildInboundHCM(ingress.go), used bybuildInboundFilterChain(mTLS, default and per-port SNI chains) andbuildInboundQUICFilterChain(HTTP/3)inboundbuildInboundCleartextFilterChain(ingress.go, SPIRE off)inboundbuildCaptureHTTPFilterChain(capture.go, 18001)capture_httpbuildDefaultOutboundHTTPFilterChain(filterchain.go, 18081)outbound_httpBuildEdgeGatewayHTTPListener(routing and redirect),BuildEdgeGatewayHTTPSListener(edge.go),BuildEdgeGatewayHTTP3Listener(http3.go)edge_gw_…BuildEdgeListener(Phase 1 sharededge_http/edge_https),BuildEdgeRedirectListener(edge.go)edge_http,edge_https,edge_redirectBuildEdgeReadinessListener(edge.go, 18021)edge_readinessOne HCM is not built by that function: the health gateway (
healthgateway.go, a node-local UDS the agent's liveness loop calls). It sets no idle timeout and so runs on Envoy's 1 h default. Not changed; the newenvoy_validatetest records it as unset so a change to it is seen.The edge gateway
ApplyEdgeHardeningoverwrites the builder's value withEdgeConfig.idleTimeout, defaultedgeDefaultIdleTimeout = 3600s. Their downstream is an external client. No change in the generated config.ApplyEdgeHardening, so they had the mesh inbound's 5 minutes. Their downstream is an external client, so the mechanism of the issue applies to them unchanged. They now passedgeDefaultIdleTimeout, the same 1 h as the per-Gateway listeners. This is the one change outside the node proxy; it is one argument at two call sites if you would rather keep it out.Tests
Unit (
agent/internal/xds/proxy/idletimeout_test.go): for each listener kind, every HCM on the generated listener carries the intended value: mesh inbound mTLS (default and SNI chain), cleartext, QUIC; outbound; capture in scoped and redirect-all mode; all seven edge client-facing listeners; the edge readiness listener. The two numbers and their relations (5 min > the 30 s upstream idle timeout; 1 h > 5 min; equal to the edge default) are pinned.envoy_validate(agent/test/envoy_validate/idle_timeout_test.go,TestDownstreamIdleTimeoutFollowsWhoTheDownstreamIs): reads the idle timeout of every HCM in the node, node-cleartext, node-UDS, capture and edge bootstraps, the same bytesTestEnvoyValidatehands to the pinned proxy, and asserts 5 min forinbound, 1 h forcapture_http/outbound_http/edge_gw_*, as literals. It requires a minimum count of each kind per fixture so neither half can pass vacuously, and it fails on an HCM whose stat prefix it cannot classify.Seen red
Two temporary mutations, each reverted:
capture.goandfilterchain.gopassingpeerFacingIdleTimeout(the behaviour before this PR). Both gates failed:ingress.gopassingappFacingIdleTimeout. Both gates failed:No kind timing test
The issue asks for a kind test that holds an idle keep-alive HTTP/1.1 connection past the timeout and reuses it. It is not added. Against the old value it needs a 5-minute wait per run, and the race itself is a window of microseconds at the end of that wait, so a single attempt almost never hits it (the issue saw it once in 270,000 requests). Against the new value there is nothing to hold a connection past in CI. The property that can be gated is the configured value, which is what the
envoy_validateassertion and the unit tests do.Connection counts with a 1 h app-facing timeout
Inferred, not measured:
config.UpstreamIdleTimeout).What bounds it, from the repository:
connection_limitfilter), noglobal_downstream_max_connectionsand no downstream-connections resource monitor anywhere in the generated config or the chart's bootstrap.charts/aether/templates/agent-proxy-configmap.yaml,proxy.overload.enabled, default true,fixed_heapmonitor) is the existing backstop, and it acts on exactly this timer:reduce_timeoutsscalesHTTP_DOWNSTREAM_CONNECTION_IDLEdown to a 2 s minimum between 85 % and 95 % of the heap budget, anddisable_http_keepalivetriggers at 90 %. So under memory pressure leaked app-side connections are reclaimed regardless of the 1 h. The same mechanism means that under memory pressure the proxy closes idle HTTP/1.1 connections early again; that is deliberate shedding and was already the case.edge-configmap.yaml) has onlyshrink_heapandstop_accepting_requests, no timer scaling. That is unchanged by this PR and already applied to the per-Gateway listeners at 1 h.perConnectionBufferLimitBytes).Not measured: connection counts per pod under churn on a cluster with this change. Worth watching
http.capture_http.downstream_cx_activeper node on the first soak.Runbook
docs/runbook.md, section 8, new entry "An HTTP/1.1 client gets a reset on a reused keep-alive connection (#1350)": the two timeouts, the rule (the server's idle timeout must exceed the client's on the app-facing side; HTTP/1.1 has no GOAWAY), the signature, and what to check.Verification
bazel test //agent/internal/... //agent/test/...: 32 of 32 pass.bazel test --config=race //agent/internal/xds/proxy:proxy_test //agent/test/envoy_validate:envoy_validate_test: pass.bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...: pass.make format-check: pass.make gazelle: run, twoBUILD.bazelfiles updated for the new test files.Not verified
200/DCrow from the issue's run 2 (the same race seen from the proxy side, unproven there) is not investigated here.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr