-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[grpc] Envoy/Googe-Grpc-lib base64 encode "-bin" client init-metadata #39026
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
Conversation
Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
…oogle grpc "-bin" initial metadata Signed-off-by: Xin Zhuang <stevenzzz@google.com>
…ocessing Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
…ponse for Envoy-grpc (less test breakages) Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
|
/assign @yanjunxiang-google Hey Yanjun, could you give it a pass? |
|
@kyessenov FYI |
|
/assign @yanavlasov |
|
/retest |
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
| Http::HeaderMap& header_map) { | ||
| // More painful copying, this time due to the mismatch in header | ||
| // representation data structures in Envoy and Google gRPC. | ||
| // Note that grpc-lib has handled the "-bin" metadata decoding. |
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.
Does it do it at send, or when set? I am worried about a case some module using gRPC SDK gets this header corrupted.
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.
It's in the gprc hpack lib I think.
check out the integration test. I am pretty sure on the wire it should be based-encoded. at least, we should not encode it on the receiving path.
(I will show you an internal integration test as example).
|
/assign @htuch |
| if (absl::EndsWith(header.key().getStringView(), "-bin")) { | ||
| bin_metadata.emplace(header.key().getStringView(), | ||
| absl::Base64Escape(header.value().getStringView())); | ||
| } |
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.
Can we directly remove the original header/value pair, and adds the new header/base-64-value pair here? That way, we can avoid the below for loop.
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.
I can not find a method from headermap to in-place replace the value of a key, let me know if you know one.
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.
I am wondering can you use setCopy() to replace the value inline, like something as below:
headers.iterate([&bin_metadata](const Http::HeaderEntry& header) {
if (absl::EndsWith(header.key().getStringView(), "-bin")) {
headers.setCopy(header.key().getStringView(), absl::Base64Escape(header.value().getStringView()));
}
}
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.
setCopy is basically remove + addCopy under the hood. this iterate() method is a "const" method, I don't fell like mutate the headermap inside it.
Let's use the somewhat ugly two loops to fix the issue.
| std::string value; | ||
| absl::Base64Unescape(header.value().getStringView(), &value); | ||
| bin_metadata[header.key().getStringView()] = std::move(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.
ditto
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.
pls see the other comment.
this method is removed in later commit.
|
|
||
| // TODO(htuch): match Google gRPC base64 encoding behavior for *-bin headers, see | ||
| // https://github.com/envoyproxy/envoy/pull/2444#discussion_r163914459. | ||
| void AsyncStreamImpl::onHeaders(Http::ResponseHeaderMapPtr&& headers, bool end_stream) { |
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.
Should we remove this TODO comments?
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.
per recent discussion, we want to drop the base64 decoding of server side -bin metadata until #39054 resolves.
| } | ||
| // Normal response headers/Server initial metadata. | ||
| if (!waiting_to_delete_on_remote_close_) { | ||
| base64UnescapeBinHeaders(*headers); |
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.
Can we just add this line base64UnescapeBinHeaders(*headers) at the original place, i.e, line 194, and keep other places in this function untouched? What's the benefit to move it to the end, and spread the logic before each return? Also, why not having if (!waiting_to_delete_on_remote_close_) check in other places? Is it a logic change?
|
Per discussion, let's not decode on the receiving path for -bin headers. This means encoding the Google-gprc-client "-bin" headers. #39054 |
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
stevenzzzz
left a comment
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.
Thanks.
Reverted the "decoding" on receiving path. adjusted tests, PTAL.
|
|
||
| // TODO(htuch): match Google gRPC base64 encoding behavior for *-bin headers, see | ||
| // https://github.com/envoyproxy/envoy/pull/2444#discussion_r163914459. | ||
| void AsyncStreamImpl::onHeaders(Http::ResponseHeaderMapPtr&& headers, bool end_stream) { |
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.
per recent discussion, we want to drop the base64 decoding of server side -bin metadata until #39054 resolves.
|
LGTM |
|
/retest |
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
|
Hey @yanavlasov, could you pls give it a maintainer bless? I'd hope someone could take care of #39054, Right now wasm filter is the only consuming server metadatas, but I am not sure if there is any meaningful application, but still good to have. |
…envoyproxy#39026) Envoy Grpc-lib en/decode base64 on -bin init-metadata Following https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md spec about "-bin" metadata. Also fixed a use-after-move bug in the grpc async-client-impl. Risk Level: LOW Testing: unit tests, integration tests. Docs Changes: Release Notes: Platform Specific Features: --------- Signed-off-by: Lizan Zhou <lizan@tetrate.io> Signed-off-by: Xin Zhuang <stevenzzz@google.com> Co-authored-by: Lizan Zhou <lizan@tetrate.io> Signed-off-by: Kyle O'Connor <oconnorkyle@google.com>
…envoyproxy#39026) Envoy Grpc-lib en/decode base64 on -bin init-metadata Following https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md spec about "-bin" metadata. Also fixed a use-after-move bug in the grpc async-client-impl. Risk Level: LOW Testing: unit tests, integration tests. Docs Changes: Release Notes: Platform Specific Features: --------- Signed-off-by: Lizan Zhou <lizan@tetrate.io> Signed-off-by: Xin Zhuang <stevenzzz@google.com> Co-authored-by: Lizan Zhou <lizan@tetrate.io> Signed-off-by: Kyle O'Connor <oconnorkyle@google.com>
Commit Message: Envoy Grpc-lib en/decode base64 on -bin init-metadata
Additional Description: Following https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md spec about "-bin" metadata.
Also fixed a use-after-move bug in the grpc async-client-impl.
Risk Level: LOW
Testing: unit tests, integration tests.
Docs Changes:
Release Notes:
Platform Specific Features: