Allow http route and cluster metadata to contain typed metadata in An…#16107
Allow http route and cluster metadata to contain typed metadata in An…#16107yanavlasov merged 22 commits intoenvoyproxy:mainfrom
Conversation
…y in addition to Struct format envoyproxy#13986. Also adding GTEST code for the new field. Signed-off-by: Yanjun Xiang <yanjunxiang@google.com>
|
/assign @yanavlasov @adisuissa |
| // Key is the reverse DNS filter name, e.g. com.acme.widget. The envoy.* | ||
| // namespace is reserved for Envoy's built-in filters. | ||
| map<string, google.protobuf.Struct> filter_metadata = 1; | ||
|
|
There was a problem hiding this comment.
Please add some comments here.
You might also want to update the comment for the Metadata message to describe the differences between the typed and non-typed filter metadata fields.
In addition, can the same key be in both filter_metadata and typed_filter_metadata. If so, what happens in this case?
BTW: if there should only be either filter_metadata or typed_filter_metadata but not both, then consider using oneof here.
There was a problem hiding this comment.
The question here is shall we deprecate filter_metadata? When we changed filter configs from Struct to Any we deprecated Struct because Any can have Struct in it.
There was a problem hiding this comment.
let's mark it as deprecated.
I think Oneof will make it harder to migrate.
For now we need both to have a smooth migration: let the metadata impl first look at typed_filter_metadata and fallback to typed_metadata when it's not populated. This way we can decouple dataplane with control plane.
There was a problem hiding this comment.
Yeah don't make it oneof, it breaks the compatibility on generated codes and violates our API policy.
There was a problem hiding this comment.
Using Oneof is infeasible here. For Oneof fields, "You can add fields of any type, except map fields and repeated fields." See https://developers.google.com/protocol-buffers/docs/proto3#oneof
There was a problem hiding this comment.
The main present issue with transitioning to using Struct-inside-of-Any is that the Metadata utility class has static methods only. It will be inefficient to use with the Struct-inside-of-Any as there is no way to cache parsed Struct. The Metadata utility class is used heavily within Envoy and also by proprietary filters, so changing its API will be challenging.
One potential way forward is to make current implementation of the Metadata class inefficient with respect to Struct-inside-of-Any and mark it as deprecated to prevent further use. And then add a new class that can cache parsed Struct from Any.
There was a problem hiding this comment.
Yeah, I think a TypedMetadata class would make sense.
There was a problem hiding this comment.
Thanks for the comments. Based on the discussion, I put Struct as deprecated, and added Any. Please take a look the latest code change and let me know whether this look good to you.
There was a problem hiding this comment.
With Struct field being deprecated, this pre_submit check scripts: " ci/run_envoy_docker.sh 'ci/do_ci.sh bazel.compile_time_options' ", is complaining below and failed the check constantly:
2021-05-07T23:34:58.2181735Z C++ exception with description "type envoy.config.core.v3.Metadata Using deprecated option 'envoy.config.core.v3.Metadata.filter_metadata' from file base.proto. This configuration will be removed from Envoy soon. Please see https://www.envoyproxy.io/docs/envoy/latest/version_history/version_history for details. If continued use of this field is absolutely necessary, see https://www.envoyproxy.io/docs/envoy/latest/configuration/operations/runtime#using-runtime-overrides-for-deprecated-features for how to apply a temporary and highly discouraged override." thrown in the test body.
2021-05-07T23:34:58.2184225Z [ FAILED ] OmitHostsRetryPredicateTest.PredicateTest (22 ms)
This happend on a lot of test cases, and one scripts run only report some of them. Once some test cases are failed as above, I just use DEPRECATED_FEATURE_TEST() to guard them. Another scripts run will report new ones. I have below questions:
- Should I continue this catch and patch style to mark all those test cases which exercising Metadata:Struct with DEPRECATED_FEATURE_TEST()?
- Is there a way to let the scripts run to the end and report all the test cases which exercising Metadata:Struct ? That way I can patch once for all.
- Is there a timing pressure to commit Any in the metadata proto? If there is, should we first commit the Any without flag Struct as deprecated? That way we deprecate Struct and fix all the text cases in a separate PR.
Please let me know your opinion.
Thanks!
There was a problem hiding this comment.
There are a lot of test cases broken by deprecating Struct field. Fixing those test cases need time. Given the timing pressure for adding Any support in this protobuf, we decided to tackle Struct field deprecation and fixing the related test cases in a separate PR.
Please let me know whether this sound good to you.
|
/assign @htuch @stevenzzzz |
stevenzzzz
left a comment
There was a problem hiding this comment.
I think we should have some consideration around the default impl of "parse(const ProtobufWkt::Any& data)" and the "fallback" behavior in populateFrom
| // Key is the reverse DNS filter name, e.g. com.acme.widget. The envoy.* | ||
| // namespace is reserved for Envoy's built-in filters. | ||
| map<string, google.protobuf.Struct> filter_metadata = 1; | ||
|
|
There was a problem hiding this comment.
let's mark it as deprecated.
I think Oneof will make it harder to migrate.
For now we need both to have a smooth migration: let the metadata impl first look at typed_filter_metadata and fallback to typed_metadata when it's not populated. This way we can decouple dataplane with control plane.
|
/assign @AdiJohn |
|
This PR needs tests in the
|
|
/wait |
Signed-off-by: Yanjun Xiang <yanjunxiang@google.com>
Thanks for the great comments! Done. please take a look! |
Thanks for the good comments. I had modified the change to cover them. Please take a look the new unit test code and let me know if something is missing and need to be added. |
|
code changes are good, but it looks like proto format picked up a lot more changes than warranted for this PR. I think this needs to have its proto format results cleaned-up. |
adisuissa
left a comment
There was a problem hiding this comment.
Thanks for working on this.
I've left a few comments.
|
/wait |
Signed-off-by: Yanjun Xiang <yanjunxiang@google.com>
…ata_proto Signed-off-by: Yanjun Xiang <yanjunxiang@google.com>
|
Waiting for #16434 commit, which is to fix the flaky testing issue. |
|
/retest |
|
Retrying Azure Pipelines: |
…ata_proto Signed-off-by: Yanjun Xiang <yanjunxiang@google.com>
|
/retest |
|
Retrying Azure Pipelines: |
|
It will need another main merge after the problem with tooling is fixed |
…ata_proto Signed-off-by: Yanjun Xiang <yanjunxiang@google.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…ata_proto Signed-off-by: Yanjun Xiang <yanjunxiang@google.com>
|
/retest |
|
Retrying Azure Pipelines: |
|
@envoyproxy/api-shepherds PTAL |
|
/retest |
|
Retrying Azure Pipelines: |
Signed-off-by: Yanjun Xiang <yanjunxiang@google.com>
4767834
…ata_proto Signed-off-by: Yanjun Xiang <yanjunxiang@google.com>
|
/retest |
|
Retrying Azure Pipelines: |
envoyproxy#16107) Allow http route and cluster metadata to contain typed metadata in Any in addition to Struct format envoyproxy#13986. Signed-off-by: Yanjun Xiang <yanjunxiang@google.com> Signed-off-by: Sixiang Gu <sgu@twitter.com>
envoyproxy#16107) Allow http route and cluster metadata to contain typed metadata in Any in addition to Struct format envoyproxy#13986. Signed-off-by: Yanjun Xiang <yanjunxiang@google.com>
Problem Description:
This PR is to address issue #13986: Allow http route and cluster metadata to contain typed metadata in Any in addition to Struct format.
Solution:
search and parse Any data first for that factory for a metadata. If Any data doesn't exist or Any parse() return nullptr, fallback to search and parse Struct data. Note if there are both Struct and Any data in a metadata but with different factory, both will be parsed and pouplated.
Created three different factories for testing above code change, and testing below cases
6.1) no data in metadata
6.2) only Struct in metadata
6.3) only Any in in metadata
6.4) both Struct and Any in metadata in the same factory
6.5) both Struct and Any in metadata in the different factory
6.6) both Struct and Any in metadata in the same factory but parse() method for Any just return nullptr.
and some other unit test to test data update, delete, and exception handling.
Testing:
The code change passed bazel test.
Release Notes:
N/A
Issues: Allow http route and cluster metadata to contain typed metadata in Any in addition to Struct format #13986
Fix #13986
Signed-off-by: Yanjun Xiang yanjunxiang@google.com
For an explanation of how to fill out the fields, please see the relevant section
in PULL_REQUESTS.md
Commit Message:
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]
[Optional API Considerations:]