Conversation
HTTP filter that can set or update dynamic metadata. Signed-off-by: Adrien Guinet <adrien@reblaze.com>
htuch
left a comment
There was a problem hiding this comment.
Looks good generally, just want to verify the details around merge.
| "//envoy/extensions/filters/http/ratelimit/v3:pkg", | ||
| "//envoy/extensions/filters/http/rbac/v3:pkg", | ||
| "//envoy/extensions/filters/http/router/v3:pkg", | ||
| "//envoy/extensions/filters/http/set_metadata/v3:pkg", |
There was a problem hiding this comment.
There was a problem hiding this comment.
I tried to added myself, but it asked for a second maintainer. Who should I add? @snowp as he is sponsoring it :) ?
There was a problem hiding this comment.
Sorry missed this answer. Done in d139579 !
source/extensions/filters/http/set_metadata/set_metadata_filter.cc
Outdated
Show resolved
Hide resolved
source/extensions/filters/http/set_metadata/set_metadata_filter.cc
Outdated
Show resolved
Hide resolved
| // The metadata namespace. | ||
| string metadata_namespace = 1 [(validate.rules).string = {min_len: 1}]; | ||
|
|
||
| // The value to update the namespace with. |
There was a problem hiding this comment.
RST link to docs providing details of the merge semantics.
api/envoy/extensions/filters/http/set_metadata/v3/set_metadata.proto
Outdated
Show resolved
Hide resolved
@htuch review: coding style + cleanup + documentation improvements Signed-off-by: Adrien Guinet <adrien@reblaze.com>
Implement a structure update algorithm that merges keys together, with a "last-one-win" strategy for scalar values, and appending for lists. Signed-off-by: Adrien Guinet <adrien@reblaze.com>
Use StructUtil::update, and update documentation about keys that have different types between the original and new structure. Signed-off-by: Adrien Guinet <adrien@reblaze.com>
Add documentation for StructUtil::update Signed-off-by: Adrien Guinet <adrien@reblaze.com>
Signed-off-by: Adrien Guinet <adrien@reblaze.com>
review by @htuch Signed-off-by: Adrien Guinet <adrien@reblaze.com>
|
@htuch it looks like this conflicts with main. Should I rebase on main and squash into two commits? (one for |
|
@aguinet in general, you should have a flow that you never rebase after creating a PR. Instead do local merges from |
htuch
left a comment
There was a problem hiding this comment.
Thanks. The merging now makes more sense. One question I have is how this extension relates to the header_to_metadata filter? https://github.com/envoyproxy/envoy/blob/main/api/envoy/extensions/filters/http/header_to_metadata/v3/header_to_metadata.proto
It seems that really we want both to behave similarly, and if we were designing from scratch they would be somewhat unified. We also have other filters, e.g. ext_authz, that set dynamic metadata base on return values from remote servers. Ideally these have aligned merge semantics.
We don't need to boil the ocean here, but having some explanation and game plan to get consistent behaviors would be helpful.
These are good questions I tried to resolve before starting this. Let me first explain my use case. What we'd like to do is leverage the matching engine to add "tags", and log this tag and/or take decisions according to these tags. This is configurable by the user in the end, and would be transformed to an envoy configuration file. As an example, I could add the tag "tag0" if the cookie "mycookie" matches a given regular expression, and another tag "tag1" if the IP comes from AS3215. I would like these two tags to be logged, and let's say block the request if the two of them are there. In order to reuse the matching engine, we would configure HTTP filters like this: In order to get the two tags, I need the current merging strategy. Now about I just checked envoy/source/extensions/filters/http/ext_authz/ext_authz.cc Lines 211 to 214 in 1f4ca4c |
Signed-off-by: Adrien Guinet <adrien@reblaze.com>
Okay. So I'll end up with a merge commit, right? Should I squash all of this before merging? |
|
Thanks for the explanation. I agree this makes sense. @envoyproxy/api-shepherds I'd like us to think about adopting this as the standard merge strategy going forward, so we don't have inconsistent merging when filters are performing dynamic metadata update.
Yes, add a merge commit. You can't squash (since this is a rebase) once a PR has started. We will squash everything prior to the main merge once approved. |
htuch
left a comment
There was a problem hiding this comment.
Thanks; a bunch of API and code comments to address, I think it's in the right shape.
/wait
|
|
||
| This filters adds or updates dynamic metadata with static data. | ||
|
|
||
| Dynamic metadata values are updated with the following scheme. If a key |
There was a problem hiding this comment.
@envoyproxy/api-shepherds this differs from MergeFrom in that it supports merging structs together, e.g. if you have a disjoint namespace things compose as expected. I think this makes sense, but flagging this for consideration in case there is some alternate merging preferences.
source/extensions/filters/http/set_metadata/set_metadata_filter.cc
Outdated
Show resolved
Hide resolved
test/extensions/filters/http/set_metadata/set_metadata_filter_test.cc
Outdated
Show resolved
Hide resolved
test/extensions/filters/http/set_metadata/set_metadata_filter_test.cc
Outdated
Show resolved
Hide resolved
test/extensions/filters/http/set_metadata/set_metadata_filter_test.cc
Outdated
Show resolved
Hide resolved
Signed-off-by: Adrien Guinet <adrien@reblaze.com>
test/common/protobuf/utility_test.cc
Outdated
|
|
||
| class StructUtilTest : public ProtobufUtilityTest { | ||
| protected: | ||
| ProtobufWkt::Struct updateSimpleStruct(ProtobufWkt::Value const& v0, |
There was a problem hiding this comment.
More const issues. Sorry if this seems nit-picky, but this style of const is different to the Envoy code base and consistency is important. There are some rare exceptions and we should fix them.
Can you just grep for const& in your difference from main and fix them all? Thanks.
There was a problem hiding this comment.
I'm sorry I thought I had checked them all... I completely understand the style consistency. Will indeed recheck this properly!
There was a problem hiding this comment.
Fixed in 45ca933 .
$ git diff main...feature/ext_add_metadata |grep 'const&' |wc -l
0
Hopefully I should be fine!
|
LGTM modulo nits and a main merge for conflict. |
Signed-off-by: Adrien Guinet <adrien@reblaze.com>
htuch
left a comment
There was a problem hiding this comment.
LGTM, thanks!
Needs main merge.
Signed-off-by: Adrien Guinet <adrien@reblaze.com>
|
@htuch main merged into the branch! Is there something else I need to do? Thanks for the time you took for all the reviews and remarks! |
|
@phlax do you know what is going on with this glint failure? |
Signed-off-by: Adrien Guinet <adrien@reblaze.com>
|
Should be fixed with 0469f86 . Added a configuration to my vim to highlight these... |
i have my editor (emacs) automatically remove/fix on save |
Signed-off-by: Adrien Guinet <adrien@reblaze.com>
|
@aguinet the clang-tidy failures seem legit, see https://dev.azure.com/cncf/envoy/_build/results?buildId=76440&view=logs&j=430ab721-bbba-5b3a-3c7b-ff111cc657fe&t=b6238472-0f30-5195-100c-623a3015b9ef |
|
\o/ Thanks a lot for the merge @htuch ! |
This extension simply allows to add user-defined dynamic metadata. This is intended to be used with matchers, so that the "result" of a matching process can imply specific metadata. See issue envoyproxy#16266 Risk Level: Medium Testing: Unit tests for the extension are added Docs Changes: A small documentation for the extension is added in docs/root/configuration/http/http_filters Signed-off-by: Adrien Guinet <adrien@reblaze.com>
Commit Message: HTTP filter that can set or update dynamic metadata.
Additional Description:
This extension simply allows to add user-defined dynamic metadata. This is intended to be used with matchers, so that the "result" of a matching process can imply specific metadata.
See issue #16266
Risk Level: Medium
Testing: Unit tests for the extension are added
Docs Changes: A small documentation for the extension is added in
docs/root/configuration/http/http_filtersRelease Notes: N/A
Platform Specific Features: N/A
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]
[Optional API Considerations:]