envoy
envoy copied to clipboard
Allow multiplexed upstream servers to half close the stream before the downstream
Commit Message:
Allow HTTP/2 (and HTTP/3) upstream servers to half close the stream before the downstream. This enables bidirectional gRPC streams where server completes streaming before the client. Behavior of HTTP/1 or TCP proxy upstream servers is unchanged and the stream is reset if the upstream server completes response before the downstream. The stream is also reset if the upstream server responds with an error status before the downstream. This behavior is disabled by default and can be enabled by setting the envoy.reloadable_features.allow_multiplexed_upstream_half_close runtime key to true.
Change details: Presently there are two places where the stream was reset when upstream half-closed.
- In the router filter's
Filter::onUpstreamCompletemethod, which covers HTTP upstreams. - In the filter manager's
FilterManager::commonEncodePrefixwhich covers local reply's by filters and TCP upstreams.
When the envoy.reloadable_features.allow_multiplexed_upstream_half_close is enabled the router filter no longer forces reset in the Filter::onUpstreamComplete and allows fully independent half closes. To preserve existing half close behavior of HTTP/1 protocol the force reset is added in the H/1 codec's ClientConnectionImpl::onMessageCompleteBase() method.
When the envoy.reloadable_features.allow_multiplexed_upstream_half_close is enabled the filter manager closes stream after it observes END_STREAM indicator in both direction, except in two cases:
- local reply.
- error (non 1xx or 2xx) response from the server.
The state_.force_close_stream_ is added to track these cases.
To preserver behavior for TCP upstream the force reset is moved into the TcpUpstream::onUpstreamData method.
Risk Level: High (flag protected, disabled by default) Testing: Unit Tests Docs Changes: No Release Notes: Yes Platform Specific Features: N/A Runtime guard: envoy.reloadable_features.allow_multiplexed_upstream_half_close Fixes #30149
As a reminder, PRs marked as draft will not be automatically assigned reviewers, or be handled by maintainer-oncall triage.
Please mark your PR as ready when you want it to be reviewed!
CC @envoyproxy/runtime-guard-changes: FYI only for changes made to (source/common/runtime/runtime_features.cc).
Sanitizer failures look related to #34354
(also please be aware I'm out for a week starting mid-week next week so there's a limited window for reviews)
Cleaning-up after main merge. Please hold off the review.
/wait
/wait
/wait
@KBaichoo @RyanTheOptimist can you PTAL?
Blocked by the #35815 . Some tests with independent half-close enabled do not pass without it.
/wait
Blocked by the #35815 . Some tests with independent half-close enabled do not pass without it.
Unblocked