-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Grpc transcoding: set content-type to json for tailer-only #8158
Conversation
Signed-off-by: Wayne Zhang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, though I'd like to coordinate this with #8009, which addresses some of conversion addressed here too.
const absl::optional<Grpc::Status::GrpcStatus> grpc_status = | ||
Grpc::Common::getGrpcStatus(trailers); | ||
if (!grpc_status || grpc_status.value() == Grpc::Status::GrpcStatus::InvalidCode) { | ||
response_headers_->Status()->value(enumToInt(Http::Code::ServiceUnavailable)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if upstream doesn't return grpc-status, it usually means the HTTP status is not 200 (5xx etc), in that case shall we override the HTTP status?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, not to set Status() if upstream grpc-status is not available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be if (!grpc_status) { return; }
before this if (grpc_status.value() == ...)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thanks for catching this crash.
@@ -365,14 +381,16 @@ Http::FilterHeadersStatus JsonTranscoderFilter::encodeHeaders(Http::HeaderMap& h | |||
|
|||
response_headers_ = &headers; | |||
|
|||
headers.insertContentType().value().setReference(Http::Headers::get().ContentTypeValues.Json); | |||
|
|||
if (end_stream) { | |||
// In gRPC wire protocol, headers frame with end_stream is a trailers-only response. | |||
// The return value from encodeTrailers is ignored since it is always continue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
cc @ascheglov |
Signed-off-by: Wayne Zhang <[email protected]>
Signed-off-by: Wayne Zhang <[email protected]>
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
I have been asked to take over this change. I will make another PR rebased off #8009 |
…e that the returned content type is `application/json`. This is required because the response body is an empty JSON body by default. Risk Level: Low Testing: Modified integration test to catch this bug. Docs Changes: None Release Notes: None Fixes: envoyproxy#5011 Ref: envoyproxy#8158 Ref: envoyproxy#8009 Signed-off-by: Teju Nareddy <[email protected]>
* When trailer indicates a gRPC error and there was no HTTP body, ensure that the returned content type is `application/json`. This is required because the response body is an empty JSON body by default. Risk Level: Low Testing: Modified integration test to catch this bug. Docs Changes: None Release Notes: None Fixes: #5011 Ref: #8158 Ref: #8009 Signed-off-by: Teju Nareddy <[email protected]>
…oxy#8312) * When trailer indicates a gRPC error and there was no HTTP body, ensure that the returned content type is `application/json`. This is required because the response body is an empty JSON body by default. Risk Level: Low Testing: Modified integration test to catch this bug. Docs Changes: None Release Notes: None Fixes: envoyproxy#5011 Ref: envoyproxy#8158 Ref: envoyproxy#8009 Signed-off-by: Teju Nareddy <[email protected]>
Signed-off-by: Wayne Zhang [email protected]
Description:
Set the content-type as application/json for tailer only response.
Risk Level: Low
Testing: integration test.
Fixes #5011