Skip to content

fix(proxy): app-facing HTTP listeners keep idle connections for 1 hour, not the mesh inbound's 5 minutes (#1350) - #1358

Merged
bpalermo merged 2 commits into
mainfrom
fix/1350-app-facing-idle-timeout
Oct 7, 2026
Merged

bpalermo merged 2 commits into
mainfrom
fix/1350-app-facing-idle-timeout

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Closes #1350

What was wrong

downstreamIdleTimeout = 5 * time.Minute set 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. buildHTTPConnectionManager no 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 in agent/internal/xds/proxy/networkfilter.go, no chart value and no flag:

  • peerFacingIdleTimeout = 5 * time.Minute
  • appFacingIdleTimeout = time.Hour (Envoy's default, now stated)

Nothing under charts/ is touched.

Every caller of buildHTTPConnectionManager

Caller HCM stat prefix Downstream Class Before After
buildInboundHCM (ingress.go), used by buildInboundFilterChain (mTLS, default and per-port SNI chains) and buildInboundQUICFilterChain (HTTP/3) inbound peer proxy peer-facing 5 min 5 min
buildInboundCleartextFilterChain (ingress.go, SPIRE off) inbound peer proxy peer-facing 5 min 5 min
buildCaptureHTTPFilterChain (capture.go, 18001) capture_http the pod's application app-facing 5 min 1 h
buildDefaultOutboundHTTPFilterChain (filterchain.go, 18081) outbound_http the pod's application app-facing 5 min 1 h
BuildEdgeGatewayHTTPListener (routing and redirect), BuildEdgeGatewayHTTPSListener (edge.go), BuildEdgeGatewayHTTP3Listener (http3.go) edge_gw_… external client edge client-facing 1 h 1 h
BuildEdgeListener (Phase 1 shared edge_http / edge_https), BuildEdgeRedirectListener (edge.go) edge_http, edge_https, edge_redirect external client edge client-facing 5 min 1 h
BuildEdgeReadinessListener (edge.go, 18021) edge_readiness kubelet readiness probe neither 5 min 5 min

One 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 new envoy_validate test records it as unset so a change to it is seen.

The edge gateway

  • The per-Gateway listeners (proposal 021 Phase 2, what a Gateway with per-Gateway addressing gets) already had 1 h: ApplyEdgeHardening overwrites the builder's value with EdgeConfig.idleTimeout, default edgeDefaultIdleTimeout = 3600s. Their downstream is an external client. No change in the generated config.
  • The Phase 1 shared listeners and the Phase 1 redirect listener do not go through 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 pass edgeDefaultIdleTimeout, 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.
  • The readiness listener is left at 5 minutes. Its only client is the kubelet probe. I did not verify from the kubelet's source that it never reuses a probe connection; I left the value alone either way.

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 bytes TestEnvoyValidate hands to the pinned proxy, and asserts 5 min for inbound, 1 h for capture_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:

  1. capture.go and filterchain.go passing peerFacingIdleTimeout (the behaviour before this PR). Both gates failed:
    --- FAIL: TestDownstreamIdleTimeoutFollowsWhoTheDownstreamIs/node_bootstrap.json
        outbound_http_test-pod/out_http_test-pod (stat_prefix outbound_http): app-facing idle timeout = 5m0s (set=true), want 1h0m0s (set=true)
    --- FAIL: TestDownstreamIdleTimeoutFollowsWhoTheDownstreamIs/capture_bootstrap.json
        capture_test-pod/capture_test-pod (stat_prefix capture_http): app-facing idle timeout = 5m0s (set=true), want 1h0m0s (set=true)
    --- FAIL: TestAppFacingListenersGetTheAppFacingIdleTimeout/outbound, /capture_scoped, /capture_redirect-all
    
  2. ingress.go passing appFacingIdleTimeout. Both gates failed:
    inbound_test-pod/in_test-pod (stat_prefix inbound): peer-facing idle timeout = 1h0m0s (set=true), want 5m0s (set=true)
    inbound_test-pod_h3/in_h3_test-pod (stat_prefix inbound): peer-facing idle timeout = 1h0m0s (set=true), want 5m0s (set=true)
    --- FAIL: TestMeshInboundKeepsThePeerFacingIdleTimeout/mtls, /cleartext, /quic
    

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_validate assertion and the unit tests do.

Connection counts with a 1 h app-facing timeout

Inferred, not measured:

  • A connection an application opens to the capture or outbound listener and then neither uses nor closes now stays on the proxy for up to 1 h instead of 5 min. Clients that close their own idle connections (the usual 30 to 120 s) are unaffected: they were already closing first.
  • The clients this changes are the ones that hold spare connections for as long as the server allows. In the issue's run 3 the capture listener idle-closed 13 to 37 such connections per node over 16 minutes; those now stay open, so expect on that order of tens more idle downstream connections per node for that kind of client, not thousands. The ~7k figure behind the 5-minute value was peer proxies on the inbound listener, which keeps 5 minutes.
  • An idle downstream connection on these listeners holds no upstream connection: the upstream pools are still reclaimed at 30 s (config.UpstreamIdleTimeout).

What bounds it, from the repository:

  • There is no per-listener connection limit (connection_limit filter), no global_downstream_max_connections and no downstream-connections resource monitor anywhere in the generated config or the chart's bootstrap.
  • The node proxy's overload manager (charts/aether/templates/agent-proxy-configmap.yaml, proxy.overload.enabled, default true, fixed_heap monitor) is the existing backstop, and it acts on exactly this timer: reduce_timeouts scales HTTP_DOWNSTREAM_CONNECTION_IDLE down to a 2 s minimum between 85 % and 95 % of the heap budget, and disable_http_keepalive triggers 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.
  • The edge's overload manager (edge-configmap.yaml) has only shrink_heap and stop_accepting_requests, no timer scaling. That is unchanged by this PR and already applied to the per-Gateway listeners at 1 h.
  • The capture and outbound listeners cap per-connection buffers at 32 KiB (perConnectionBufferLimitBytes).

Not measured: connection counts per pod under churn on a cluster with this change. Worth watching http.capture_http.downstream_cx_active per 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, two BUILD.bazel files updated for the new test files.

Not verified

  • No run against a live cluster or kind: the fix is checked as generated configuration, not as a traffic result. That the reset in the issue goes away is inferred from the mechanism the issue established.
  • The 200/DC row 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

…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
Copilot AI balanced review requested due to automatic review settings October 7, 2026 19:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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.

Copilot AI balanced review requested due to automatic review settings October 7, 2026 20:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Timeout assignments are consistent across callers and covered by unit and generated-configuration assertions, with no blocking issues identified.

0 open findings

🧠 Review effort: Balanced

@bpalermo
bpalermo merged commit 097f6ae into main Oct 7, 2026
31 checks passed
@bpalermo
bpalermo deleted the fix/1350-app-facing-idle-timeout branch October 7, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants