Skip to content

Add a proxy config key for the upstream connection idle timeout - #900

Merged
joec4i merged 1 commit into
main-bcfrom
upstream-connection-idle-timeout
Oct 19, 2026
Merged

joec4i merged 1 commit into
main-bcfrom
upstream-connection-idle-timeout

Conversation

@joec4i

@joec4i joec4i commented Oct 19, 2026 •

Copy link
Copy Markdown

Description

Adds upstream_connection_idle_timeout_ms to the proxy config. It sets common_http_protocol_options.idle_timeout on every http, http2 and grpc upstream cluster. Envoy's default is 1h and Consul had no way to change it. Unset by default, so existing config doesn't change. 0 disables the timeout, and negative values are ignored.

When an intention change drains a destination sidecar, Envoy closes the connections still idle at the end of the drain. If a stateful firewall between the hosts has already forgotten an idle connection (GCP's VPC firewall does after 10 minutes), it drops that FIN, the caller keeps the connection, and its next request gets a reset and a 503. Setting this in proxy-defaults below the firewall's timeout makes callers close idle connections first. tcp upstreams aren't covered; theirs is the tcp_proxy idle timeout.

To be backported to 1.20.x-bc and 1.22.x-bc after merge.

Testing & Reproduction steps

  • Three new golden cases: custom-upstream-connection-idle-timeout, its -http2 variant, and terminating-gateway-upstream-connection-idle-timeout. No existing goldens change. agent/xds and agent/proxycfg tests pass.
  • Nomad 2.0.7 with Envoy 1.38.4 sidecars (--drain-time-s 30), and a 20s conntrack timeout on the Nomad client standing in for the firewall. Each run: one request, an intention change on the destination, then another request 40s later. Without the key, the caller's socket is still ESTABLISHED after the drain and the request gets a 503 (upstream_cx_destroy_remote_with_active_rq +1). With it set to 10000, the caller closes the connection at 10s (upstream_cx_idle_timeout +1) and the request gets a 200. Same on v1.20.6-bc.2 with Envoy 1.33.14.

Links

PR Checklist

  • updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • not a security concern

🤖 Generated with Claude Code

@joec4i
joec4i marked this pull request as ready for review October 19, 2026 04:25
@joec4i
joec4i requested a lite review from Copilot October 19, 2026 04:25

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.

🟡 Changes recommended

Negative timeout validation and snapshot deep-copy handling remain unresolved; release documentation is also missing.

3 open issues
What changed in this PR

Adds upstream_connection_idle_timeout_ms for HTTP, HTTP/2, and gRPC upstream clusters.

Changes:

  • Adds proxy configuration parsing.
  • Applies Envoy upstream idle timeouts.
  • Adds XDS golden coverage.
File Reviewed change
agent/​xds/​testdata/​secrets/​custom-upstream-connection-idle-timeout.latest.golden Adds HTTP golden output.
agent/​xds/​testdata/​secrets/​custom-upstream-connection-idle-timeout-http2.latest.golden Adds HTTP/2 golden output.
agent/​xds/​testdata/​routes/​custom-upstream-connection-idle-timeout.latest.golden Adds HTTP route golden output.
agent/​xds/​testdata/​routes/​custom-upstream-connection-idle-timeout-http2.latest.golden Adds HTTP/2 route golden output.
agent/​xds/​testdata/​listeners/​custom-upstream-connection-idle-timeout.latest.golden Adds listener golden output.
agent/​xds/​testdata/​listeners/​custom-upstream-connection-idle-timeout-http2.latest.golden Adds HTTP/2 listener golden output.
agent/​xds/​testdata/​endpoints/​custom-upstream-connection-idle-timeout.latest.golden Adds endpoint golden output.
agent/​xds/​testdata/​endpoints/​custom-upstream-connection-idle-timeout-http2.latest.golden Adds HTTP/2 endpoint golden output.
agent/​xds/​testdata/​clusters/​custom-upstream-connection-idle-timeout.latest.golden Verifies configured cluster timeout output.
agent/​xds/​testdata/​clusters/​custom-upstream-connection-idle-timeout-http2.latest.golden Verifies HTTP/2 cluster timeout output.
agent/​xds/​resources_test.go Registers the new golden test cases.
agent/​xds/​config/​config.go Defines the new proxy configuration field.
agent/​xds/​clusters.go Applies the timeout to upstream clusters.

Review effort: Lite

Comment thread agent/xds/clusters.go
Comment thread agent/xds/config/config.go
Comment thread agent/xds/config/config.go
@joec4i
joec4i force-pushed the upstream-connection-idle-timeout branch from 96354b0 to 9b7fe43 Compare October 19, 2026 04:33
@joec4i
joec4i requested a lite review from Copilot October 19, 2026 04: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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

🟡 Changes recommended

The timeout helper must also be applied to terminating-gateway service clusters.

1 open issue
1 file not reviewed
  • agent/proxycfg/proxycfg.deepcopy.go: Generated file

Review effort: Lite

Comment thread agent/xds/clusters.go Outdated
upstream_connection_idle_timeout_ms sets common_http_protocol_options
idle_timeout on every http, http2 and grpc upstream cluster. Envoy's default
is 1h and Consul had no way to change it.

When an intention change drains a destination sidecar's public listener, Envoy
closes the connections still idle at the end of the drain. A stateful
firewall between the two hosts that has already forgotten an idle connection
(GCP's VPC firewall does after 10 minutes) drops that FIN, so the caller keeps
the connection and its next request on it gets a reset and a 503. Closing idle
upstream connections on the caller before the firewall forgets them, set
globally in proxy-defaults, avoids that.

Unset by default, so existing proxies get the same config as before. 0
disables the timeout, and negative values are ignored because Envoy would
reject them along with every HTTP upstream cluster.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joec4i
joec4i force-pushed the upstream-connection-idle-timeout branch from 9b7fe43 to e9627b2 Compare October 19, 2026 05:27
@joec4i
joec4i merged commit b6b3c4f into main-bc Oct 19, 2026
3 checks passed
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.

3 participants