Repository navigation
http: allowing 100 then 500 - #12185
Conversation
Signed-off-by: Alyssa Wilk <[email protected]>
|
The one thing I don't like about this PR is the change to sendLocalResponse. |
Signed-off-by: Alyssa Wilk <[email protected]>
mattklein123
left a comment
There was a problem hiding this comment.
Thanks for the fix. LGTM at a high level with some small comments. Thank you!
/wait
| * If a response has already started (which should only happen if this is called by the router | ||
| * filter) this will either ship the reply directly to the downstream codec, or reset the stream. |
There was a problem hiding this comment.
Technically I don't think this needs to be true, right? I think an intermediate filter could also attempt to send a local reply in error cases when the response was already started?
| Network::Socket::OptionsSharedPtr upstream_options_; | ||
| std::unique_ptr<RouteConfigUpdateRequester> route_config_update_requester_; | ||
| std::unique_ptr<Tracing::CustomTagMap> tracing_custom_tags_{nullptr}; | ||
| bool response_headers_encoded_{}; |
| state_.destroyed_, | ||
| Utility::EncodeFunctions{ | ||
| [&](ResponseHeaderMap& response_headers, Code& code, std::string& body, | ||
| absl::string_view& content_type) -> void { | ||
| connection_manager_.config_.localReply().rewrite( | ||
| request_headers_.get(), response_headers, stream_info_, code, body, content_type); | ||
| }, | ||
| [&](ResponseHeaderMapPtr&& response_headers, bool end_stream) -> void { | ||
| if (modify_headers != nullptr) { | ||
| modify_headers(*response_headers); | ||
| } | ||
| response_headers_ = std::move(response_headers); | ||
| encodeHeadersInternal(*response_headers_, end_stream); | ||
| }, | ||
| [&](Buffer::Instance& data, bool end_stream) -> void { | ||
| encodeDataInternal(data, end_stream); | ||
| }}, | ||
| Utility::LocalReplyData{Grpc::Common::hasGrpcContentType(*request_headers_), code, body, | ||
| grpc_status, state_.is_head_request_}); |
There was a problem hiding this comment.
This is mostly copied from below and is somewhat nuanced and took me a couple of reads to see the difference. Is there any way to share this with just a bool that switches between internal vs. not? Up to you.
| } | ||
| } | ||
|
|
||
| // stream_info_.response_code_ is used by trySendLocalResponse to determine if non-informational |
There was a problem hiding this comment.
Out of date comment? Also, for the next reader, can you add a bit more of a comment on where informational headers are sent? I assume that is in encode100Continue or something like that? It's not completely clear from a quick read why they wouldn't come through here. Along these lines, maybe rename to non_informational_response_headers_encoded_?
Signed-off-by: Alyssa Wilk <[email protected]>
|
|
||
| stream_info_.setResponseCodeDetails(details); | ||
| if (response_headers_.get() == nullptr) { | ||
| // If the response has not started at all, send the response through the filter chain. |
There was a problem hiding this comment.
something for my own knowledge, if you send the response through the filter chain, do you have to explicitly call allowIteration() in case it was stopped?
Fixing a bug where the router filter wouldn't send a local response had already been sent. This could have been fixed in a lower-risk fashion by keeping the existing logic, and doing sendLocalReply only iff non-informational headers had not been sent. This design has the added benefit of being usable in a follow-up PR to call sendLocalResponse from encoder filters which currently force-reset the stream on the response path Risk Level: Medium/High Testing: updated unit tests, new integration tests Docs Changes: n/a Release Notes: inline Runtime guard: envoy.reloadable_features.allow_500_after_100 Fixes envoyproxy#12131 Signed-off-by: Alyssa Wilk <[email protected]> Signed-off-by: Kevin Baichoo <[email protected]>
Fixing a bug where the router filter wouldn't send a local response had already been sent. This could have been fixed in a lower-risk fashion by keeping the existing logic, and doing sendLocalReply only iff non-informational headers had not been sent. This design has the added benefit of being usable in a follow-up PR to call sendLocalResponse from encoder filters which currently force-reset the stream on the response path Risk Level: Medium/High Testing: updated unit tests, new integration tests Docs Changes: n/a Release Notes: inline Runtime guard: envoy.reloadable_features.allow_500_after_100 Fixes envoyproxy#12131 Signed-off-by: Alyssa Wilk <[email protected]> Signed-off-by: scheler <[email protected]>
Fixing a bug where the router filter wouldn't send a local response had already been sent.
This could have been fixed in a lower-risk fashion by keeping the existing logic, and doing sendLocalReply only iff non-informational headers had not been sent. This design has the added benefit of being usable in a follow-up PR to call sendLocalResponse from encoder filters which currently force-reset the stream on the response path
Risk Level: Medium/High
Testing: updated unit tests, new integration tests
Docs Changes: n/a
Release Notes: inline
Runtime guard: envoy.reloadable_features.allow_500_after_100
Fixes #12131