Repository navigation
router: remove allow_multiplexed_upstream_half_close, keep half close for TCP upstreams - #48648
Conversation
56f42ba to
6ba9a12
Compare
|
/retest |
|
@phlax the |
6ba9a12 to
244fbfc
Compare
|
/retest |
Commit Message: tools/code: Run the code check in `check_test` directly Additional Description: The `//tools/code:checked` genrule ran the code checker with `|| :`, so a crash of the checker was a successful action. Its cache key only changes with `//bazel:volatile-scm-hash`, so a cached crash is replayed by every later run on the same tree. On #48648, both attempts of https://github.com/envoyproxy/envoy/actions/runs/40078303704 failed `//tools/code:check_test` with identical output (`ImportError: cannot import name 'version' from 'packaging'`), with `checked` served from the remote cache. The only earlier run on that tree, https://github.com/envoyproxy/envoy/actions/runs/40078213656, was cancelled during that test. How the checker crashed there is not confirmed. This removes the genrule and runs the checker in `check_test` directly. The test fails if the checker exits non-zero or prints anything. Failed test results are not cached, so a crash is retried on the next run, and passing results are still cached on the same key. Risk Level: Low (CI only) Testing: `buildifier` on `tools/code/BUILD`. Not built locally; relying on the `format` job of this PR. Docs Changes: N/A Release Notes: N/A Platform Specific Features: N/A AI assistance: prepared with AI assistance (Cursor agent). We reviewed and understand all of it. --------- Signed-off-by: William Dauchy <[email protected]>
… for TCP upstreams Remove the envoy.reloadable_features.allow_multiplexed_upstream_half_close runtime guard. HTTP upstreams no longer half close the stream before the downstream, so the compensating resets in the HTTP/1 codec and in TcpUpstream go away. Independent half close is kept for TCP upstreams with an HTTP/2 or HTTP/3 downstream, where END_STREAM maps to a TCP FIN (RFC 9113 section 8.5). The router enables it per stream when the conn pool supports it, through DownstreamStreamFilterCallbacks::enableHalfClose(). HTTP/1 downstreams can only end a CONNECT response by closing the connection, so they keep the reset. It is guarded by envoy.reloadable_features.tcp_tunnel_allow_upstream_half_close, on by default. Signed-off-by: William Dauchy <[email protected]>
244fbfc to
a10fdee
Compare
|
/retest |
| "envoy.reloadable_features.tcp_tunnel_allow_upstream_half_close")) { | ||
| return; | ||
| } | ||
| // HTTP/1 can only signal the end of a CONNECT response by closing the connection. |
There was a problem hiding this comment.
I think technically server can half-close its end of the tunnel in H/1 case. But we can deal with this later.
|
This also removes the fix for #30149, which was a gRPC report, and we still depend on it for bidirectional gRPC streaming. A gRPC server may send its status before the client half-closes, for example to fail a long-lived bidi call on an invalid request. Without independent half close, Envoy resets the downstream stream as soon as the upstream completes. Response data still waiting for the client's flow-control window and the trailers with the status, are then lost. We reproduced this with an HTTP/2 upstream that sends 2 MB plus
RFC 9113 §8.1 allows a reset after a complete response, but here it cuts the response short, so clients rightly report an error. Could independent half close be kept for HTTP/2 and HTTP/3 upstreams, at least behind a guard like the new Update: #48857 (fixing #48192) would most likely fix this too: it defers the reset until the response has been fully encoded, which covers exactly the "unset" rows above. With that change, independent half close would no longer be needed for HTTP/2 upstreams, so removing the flag would be fine for us, as long as #48857 lands in the same release as this PR. |
- encodeTrailersBase(): with http2_deferred_reset_waits_for_end_stream, call onLocalEndStream() for empty trailers too, so a deferred reset that waits for END_STREAM is bounded by the stream flush timeout. Add codec tests for the timeout and for the guard-disabled behavior. - OnlyStreamWithEndStreamSentIsReset: stop the loop once stream 2 is reset, as the stream frees the scheduled callback when it closes. - Pass lambdas directly instead of testing::Invoke/InvokeWithoutArgs, which main removed in envoyproxy#48804. - ConnectTerminationLargeResponseIntegrationTest: disable tcp_tunnel_allow_upstream_half_close (envoyproxy#48648), as with half close the upstream FIN ends the stream instead of resetting it. - Add MultiplexedIntegrationTest.LargeUpstreamResponseBeforeRequestCompleteSmallWindow: a non-CONNECT HTTP/2 stream whose response completes before the request, with the response blocked by flow control. It fails without the fix. Signed-off-by: Oliver Domokos <[email protected]>
Commit Message: router: remove allow_multiplexed_upstream_half_close, keep half close for TCP upstreams
Remove the
envoy.reloadable_features.allow_multiplexed_upstream_half_closeruntime guard. HTTP upstreams no longer half close before the downstream, so the compensating resets in the HTTP/1 codec and inTcpUpstreamare removed.Half close is kept for TCP upstreams with an HTTP/2 or HTTP/3 downstream, where END_STREAM maps to a TCP FIN (RFC 9113 §8.5). HTTP/1 downstreams can only end a CONNECT response by closing the connection, so they keep the reset. The router enables it per stream when the conn pool supports it (
GenericConnPool::supportsIndependentHalfClose()), through the newDownstreamStreamFilterCallbacks::enableHalfClose().Additional Description:
Follows @yanavlasov's proposal in #48316 to remove the flag. TCP tunnels still need half close: without it, an origin that FINs after a download resets the stream and the client gets a truncated body (#47378). This supersedes the TCP part of #47378 (cc @fl0Lec) and makes #48316 unnecessary.
The decision uses the conn pool, not the route: the
httpupstream factory ignores the requested protocol, so a CONNECT route can still reach an HTTP/1 upstream (the #48316 crash path).Risk Level: Medium. TCP tunnels now end with an end of stream instead of a reset when the upstream half closes first. Revert with
envoy.reloadable_features.tcp_tunnel_allow_upstream_half_close=false.Testing: Router unit tests, and
ConnectTerminationIntegrationTest.UpstreamHalfCloseKeepsTunnelOpen/UpstreamCloseWithHalfCloseDisabled. Tests that only covered HTTP upstream half close are removed.Docs Changes: HTTP lifecycle in
http_connection_management.rstandlife_of_a_request.rst.Release Notes: Added.
Platform Specific Features: N/A
Runtime guard:
envoy.reloadable_features.tcp_tunnel_allow_upstream_half_closeAI assistance: prepared with AI assistance (Cursor agent). We reviewed and understand all of it.