-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
header to metadata: add base64 encode and protobuf value type #7796
Conversation
Signed-off-by: Yangmin Zhu <[email protected]>
For the second point, just a quick question, do we prefer to add a new |
Can something be done to avoid serializing the metadata on every request, and do it only once during filter construction? That's the critical part in the existing istio implementation. |
cc @mandarjog |
// `Base64Url <https://tools.ietf.org/html/rfc4648#section-5>`_ encoded string of | ||
// serialized `protobuf.Value | ||
// <https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto#L62>`_ | ||
BASE64URL_SERIALIZED = 2; |
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.
This is counter intuitive from API stand point without reading the comment above, from reading the implementation, I'd say make this VALUE
or PROTOBUF_VALUE
, and have another enum for the encoding to express it, since which base64 or not is orthogonal to value type here, WDYT?
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.
That looks a cleaner API though I imagine the base64
option is likely to be always used only with PROTOBUF_VALUE
?
I'm fine with the suggestion, @rgs1 WDYT?
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 is possible for someone to use STRING with BASE64 with some non header safe character sets (UTF-8), and when you add more binary types here it will help anyway.
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.
yeah i like Lizan's suggestion (PROTOBUF_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.
Thanks, updated.
@kyessenov Hmm, not sure I understand your question. Could you clarify a little bit? Thanks. I thought the header value is only known on request so how can we do the serialization only during filter construction? One thing I can think of right now is to use a cache to avoid the serialization on every request. Is this what you're suggesting? |
@yangminzhu The filter I referenced sends node metadata, which is always the same across all requests. For example, pod labels. |
@kyessenov I see, Are you referring to the client side sending the metadata via header? I think that is not covered in this PR and will be solved with the new This PR is about the server side decoding the header, Is there anything else we should take care of here? thanks! |
@yangminzhu @kyessenov take a look on #2394 while it is not completely standardized though it is partially implemented. cc @soya3129 for current status. |
IIUC it allows per connection metadata exchange as well as per stream metadata exchange. |
@lizan Yes, we're are aware of H2 metadata. It's very cool, but unfortunately the world has not even moved to H2 yet, so it'll cause issues with inter-operability with other proxies (or even gRPC). |
source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.cc
Outdated
Show resolved
Hide resolved
source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.cc
Outdated
Show resolved
Hide resolved
@yangminzhu This is fine for extracting a request header to metadata. I'm still not entirely sure how this works for extracting a response headers from an upstream host, to be usable as a replacement for the istio filter. |
The h-t-m filter works for both request/response headers, fwiw. Also, do we need a separate |
@rgs1 Gotcha, I didn't see response rules at first. |
Signed-off-by: Yangmin Zhu <[email protected]>
@lizan @rgs1 @kyessenov PTAL, the coverage seems failing for some network error, thank you. |
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.
This seems very useful. Thanks for looking into it. To start with, I have a question about the API, once we get that nailed down I'll look at the rest more closely.
api/envoy/config/filter/http/header_to_metadata/v2/header_to_metadata.proto
Outdated
Show resolved
Hide resolved
Signed-off-by: Yangmin Zhu <[email protected]>
Signed-off-by: Yangmin Zhu <[email protected]>
source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.cc
Outdated
Show resolved
Hide resolved
Signed-off-by: Yangmin Zhu <[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.
@envoyproxy/api-shepherds API LGTM
Signed-off-by: Yangmin Zhu <[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, thanks. just one nit.
source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.cc
Outdated
Show resolved
Hide resolved
test/extensions/filters/http/header_to_metadata/header_to_metadata_filter_test.cc
Outdated
Show resolved
Hide resolved
Signed-off-by: Yangmin Zhu <[email protected]>
@htuch Would you mind to approve for the API again? I pushed a new commit to resolve some other comments, no new changes in API. Thank you. |
No API changes since last API review, just merged. |
Signed-off-by: Yangmin Zhu [email protected]
For the first point in #7771 for converting arbitrary protobuf value from header to metadata.
cc @rgs1 @kyessenov
For an explanation of how to fill out the fields, please see the relevant section
in PULL_REQUESTS.md
Description:
Risk Level: Low
Testing: Unit tests
Docs Changes: Updated version_history.rst
Release Notes: Updated version_history.rst
[Optional Fixes #Issue]
[Optional Deprecated:]