Skip to content

Grpc transcoding: set content-type to json for tailer-only#8158

Closed
qiwzhang wants to merge 3 commits intoenvoyproxy:masterfrom
qiwzhang:grpc_trailer_fix
Closed

Grpc transcoding: set content-type to json for tailer-only#8158
qiwzhang wants to merge 3 commits intoenvoyproxy:masterfrom
qiwzhang:grpc_trailer_fix

Conversation

@qiwzhang
Copy link
Copy Markdown
Contributor

@qiwzhang qiwzhang commented Sep 5, 2019

Signed-off-by: Wayne Zhang qiwzhang@google.com

Description:

Set the content-type as application/json for tailer only response.

Risk Level: Low
Testing: integration test.
Fixes #5011

Signed-off-by: Wayne Zhang <qiwzhang@google.com>
@qiwzhang
Copy link
Copy Markdown
Contributor Author

qiwzhang commented Sep 5, 2019

@lizan will this change address #5011?

@htuch htuch requested a review from lizan September 6, 2019 00:28
Copy link
Copy Markdown
Member

@lizan lizan left a 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));
Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

@ascheglov ascheglov Sep 8, 2019

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() == ...).

Copy link
Copy Markdown
Contributor Author

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.


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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

delete this line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@lizan
Copy link
Copy Markdown
Member

lizan commented Sep 6, 2019

cc @ascheglov

Signed-off-by: Wayne Zhang <qiwzhang@google.com>
Signed-off-by: Wayne Zhang <qiwzhang@google.com>
@stale
Copy link
Copy Markdown

stale bot commented Sep 16, 2019

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!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Sep 16, 2019
@lizan
Copy link
Copy Markdown
Member

lizan commented Sep 19, 2019

@qiwzhang #8009 is now in, can you rebase accordingly?

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Sep 19, 2019
@lizan lizan added the waiting label Sep 20, 2019
@nareddyt
Copy link
Copy Markdown
Contributor

I have been asked to take over this change. I will make another PR rebased off #8009

nareddyt added a commit to nareddyt/envoy that referenced this pull request Sep 20, 2019
…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 <nareddyt@google.com>
@qiwzhang qiwzhang closed this Sep 20, 2019
@qiwzhang qiwzhang deleted the grpc_trailer_fix branch September 20, 2019 23:09
lizan pushed a commit that referenced this pull request Sep 24, 2019
* 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 <nareddyt@google.com>
danzh2010 pushed a commit to danzh2010/envoy that referenced this pull request Oct 4, 2019
…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 <nareddyt@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

grpc-json transcoder: stream return type always returns 200 even in case of errors

4 participants