Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make grpc_http1_reverse_bridge return HTTP 200. #31047

Merged
merged 3 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelogs/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ removed_config_or_runtime:
# *Normally occurs at the end of the* :ref:`deprecation period <deprecated>`

new_features:
- area: grpc reverse bridge
change: |
Change HTTP status to 200 to respect the gRPC protocol. This may cause problems for incorrect gRPC clients expecting the filter
to preserve HTTP 1.1 responses. This behavioral change can be temporarily reverted by setting runtime guard
``envoy.reloadable_features.grpc_http1_reverse_bridge_change_http_status`` to false.

deprecated:
1 change: 1 addition & 0 deletions source/common/runtime/runtime_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ RUNTIME_GUARD(envoy_reloadable_features_enable_connect_udp_support);
RUNTIME_GUARD(envoy_reloadable_features_enable_intermediate_ca);
RUNTIME_GUARD(envoy_reloadable_features_enable_zone_routing_different_zone_counts);
RUNTIME_GUARD(envoy_reloadable_features_ext_authz_http_send_original_xff);
RUNTIME_GUARD(envoy_reloadable_features_grpc_http1_reverse_bridge_change_http_status);
RUNTIME_GUARD(envoy_reloadable_features_grpc_http1_reverse_bridge_handle_empty_response);
RUNTIME_GUARD(envoy_reloadable_features_handle_uppercase_scheme);
RUNTIME_GUARD(envoy_reloadable_features_hmac_base64_encoding_only);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ Http::FilterHeadersStatus Filter::encodeHeaders(Http::ResponseHeaderMap& headers
// until then.
grpc_status_ = grpcStatusFromHeaders(headers);

// gRPC clients expect that the HTTP status will always be 200.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should do it only when it is a gRPC response. For regular HTTP responses the status should not be modified.

Also as this is a user visible change it will require a runtime flag protection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding is that if this filter is active (enabled_ is only set to true if the request headers indicate it's a gRPC request), then the response is a gRPC response. Thus, my code change only applies when it is a gRPC response.

Could you link me to an example PR or docs for enabling runtime flag protection?

Copy link
Member

Choose a reason for hiding this comment

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

if (Runtime::runtimeFeatureEnabled(
"envoy.reloadable_features.grpc_http1_reverse_bridge_change_http_status")) {
headers.setStatus(enumToInt(Http::Code::OK));
}

if (Runtime::runtimeFeatureEnabled(
"envoy.reloadable_features.grpc_http1_reverse_bridge_handle_empty_response")) {
// This is a header-only response, and we should prepend the gRPC frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ TEST_F(ReverseBridgeTest, GrpcRequestInternalError) {
{{":status", "400"}, {"content-type", "application/x-protobuf"}});
EXPECT_EQ(Http::FilterHeadersStatus::Continue, filter_->encodeHeaders(headers, false));
EXPECT_THAT(headers, HeaderValueOf(Http::Headers::get().ContentType, "application/grpc"));
EXPECT_THAT(headers, HeaderValueOf(Http::Headers::get().Status, "200"));

{
// First few calls should drain the buffer
Expand Down