Skip to content
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

ext_proc: send and receive dynamic metadata #30747

Merged
merged 47 commits into from
Jan 30, 2024

Conversation

jbohanon
Copy link
Contributor

@jbohanon jbohanon commented Nov 6, 2023

extract metadata changes from #29069

Commit Message:
Introduce the ability to send dynamic metadata in the External Processing Request. Also implements the API for returning dynamic metadata as part of the External Processing Response.
Additional Description:
Risk Level: Low
Testing:

Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @abeyad
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #30747 was opened by jbohanon.

see: more, trace.

@jbohanon
Copy link
Contributor Author

jbohanon commented Nov 6, 2023

@markdroth you had previously approved the API changes on the now-closed PR (#29069) from which this work was extracted. What do you think about the API as-is and the comments above? I'm happy to change the API naming if it's deemed necessary, but as we have some internal references and some customers using this early-access provisional API, it'd be preferred to keep the naming if the benefit is marginal.

@abeyad
Copy link
Contributor

abeyad commented Nov 9, 2023

@markdroth you had previously approved the API changes on the now-closed PR (#29069) from which this work was extracted. What do you think about the API as-is and the comments above? I'm happy to change the API naming if it's deemed necessary, but as we have some internal references and some customers using this early-access provisional API, it'd be preferred to keep the naming if the benefit is marginal.

I chatted w/ Mark and he clarified to me that "dynamic" in this case is redundant since the term metadata in xDS is used specifically for dynamic metadata, so please ignore those changes. But as a general rule, the API should be amenable to fixes and "getting it right" before being relied upon, and changes made up front are far less costly than mistakes down the road. But I understand you got approval from Mark before on this API change so your case is a bit different.

Also, if you can please address the comments around adding a . to the end of the sentence comments.

Happy to approve this PR after that's done, thanks for your effort on this!

Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
@jbohanon jbohanon force-pushed the feature/ext_proc/dynamic-metadata branch from ca0d0eb to cbfc6e7 Compare November 9, 2023 16:34
@abeyad
Copy link
Contributor

abeyad commented Nov 9, 2023

Note: please avoid force pushing commits. According to the contributing guide:

Once your PR is under review, please do not rebase it. If you rebase, you will need to force push to github, 
and github's user interface will force your reviewer to review the PR from scratch rather than simply look 
at your latest changes. It's much easier to review new commits and/or merges. We squash rebase the final 
merged commit so the number of commits you have in the PR don't matter. Again once your PR is assigned 
a reviewer, unless you need to fix DCO please do not force push.

If you need to resolve merge conflicts:

branch=$(git status|head -1|cut -f3 -d\ )
git checkout main
git pull
git checkout "$branch"
git merge main

abeyad
abeyad previously approved these changes Nov 9, 2023
Copy link
Contributor

@abeyad abeyad left a comment

Choose a reason for hiding this comment

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

LGTM /api

@repokitteh-read-only repokitteh-read-only bot removed the api label Nov 9, 2023
@abeyad abeyad assigned tyxia and unassigned yanavlasov Nov 9, 2023
@abeyad
Copy link
Contributor

abeyad commented Nov 9, 2023

Adding @tyxia as a code owner

Copy link
Member

@tyxia tyxia left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

Overall approach make senses to me. Left some comments after first pass.

@@ -73,10 +73,19 @@ class ProcessorState : public Logger::Loggable<Logger::Id::ext_proc> {
};

explicit ProcessorState(Filter& filter,
envoy::config::core::v3::TrafficDirection traffic_direction)
envoy::config::core::v3::TrafficDirection traffic_direction,
std::vector<std::string> untyped_forwarding_namespaces,
Copy link
Member

Choose a reason for hiding this comment

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

We should avoid the copy here. Please pass argument by reference or use absl::Span (https://abseil.io/tips/93).

Please also fix other places in this PR

source/extensions/filters/http/ext_proc/processor_state.h Outdated Show resolved Hide resolved

// Describes which typed or untyped dynamic metadata namespaces to accept from
// the external processing server. Set to empty or leave unset to disallow writing
// any received dynamic metadata. Receiving of typed metadata is not supported.
Copy link
Member

Choose a reason for hiding this comment

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

Re: receiving of typed metadata is not supported: Looks like it is because that only google.protobuf.Struct is defined in ProcessingResponse? Actually I am not very sure why protobuf.Any is not defined. Though this could be out of scope of this PR.

cc @gbrail

source/extensions/filters/http/ext_proc/ext_proc.cc Outdated Show resolved Hide resolved
source/extensions/filters/http/ext_proc/ext_proc.h Outdated Show resolved Hide resolved
@@ -79,7 +79,7 @@ class ExtProcIntegrationTest : public HttpIntegrationTest,
scoped_runtime_.mergeValues(
{{"envoy.reloadable_features.send_header_raw_value", header_raw_value_}});
scoped_runtime_.mergeValues(
{{"envoy_reloadable_features_immediate_response_use_filter_mutation_rule",
{{"envoy.reloadable_features.immediate_response_use_filter_mutation_rule",
Copy link
Member

@tyxia tyxia Nov 14, 2023

Choose a reason for hiding this comment

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

Thanks for fixing this!

Could you please also add integration test cases for send/receive dynamic metadata that is introduced in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tyxia I have added integration testing for this feature.

@adisuissa
Copy link
Contributor

@yanjunxiang-google can you PTAL?
Also assigning Yan as ext_proc code owner.
/assign @yanavlasov

@yanavlasov
Copy link
Contributor

Waiting for comments to be addressed.

/wait

- pass vectors by reference instead of copying
- cleaner check for receiving namespaces
- logging when returned metadata doesn't match any configured namespaces
- pass response by reference instead of smart pointer

Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
@jbohanon
Copy link
Contributor Author

jbohanon commented Jan 25, 2024

/retest

edit: attempted to rerun failed Azure Pipelines job. This did not have any effect.

Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
@jbohanon
Copy link
Contributor Author

jbohanon commented Jan 25, 2024

/retest

edit: attempted to rerun failed GitHub Actions job. This did not have any effect.

Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
@jbohanon
Copy link
Contributor Author

@yanavlasov this is ready now, PTAL, thanks

@tyxia some changes were made since you reviewed, namely the responsibility for the merging of more-specific namespaces lists into less-specific namespaces lists has been offloaded to the control-plane. This simplified the API and merge logic. Notably, I was still getting junk memory values if I did not store the new merged vectors for namespaces, presumably due to copying into absl::optional, so these vectors are stored on the Filter object to extend lifetime.

Comment on lines 199 to 201
untyped_forwarding_namespaces_(more_specific.untypedForwardingMetadataNamespaces()),
typed_forwarding_namespaces_(more_specific.typedForwardingMetadataNamespaces()),
untyped_receiving_namespaces_(more_specific.untypedReceivingMetadataNamespaces()) {}
Copy link
Member

@tyxia tyxia Jan 27, 2024

Choose a reason for hiding this comment

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

@jbohanon I agree with getting rid of merge proto. That probably has unnecessary complexity that we don' need for now.

However, I am not sure that we should let control plane do the merge . At least it seems to be inconsistent with existing ext_proc behavior. e.g., mergeProcessingMode, grpc_service_ above. Can we just have similar simple logic : if most_specific has namespaces, use that; if most_specific doesn't , use less_specific.

This is probably not critical thing to this PR and I am ok with discussing it in a separate PR. Small PR which can help review and move things faster is preferred and appreciated .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

However, I am not sure that we should let control plane do the merge . At least it seems to be inconsistent with existing ext_proc behavior. e.g., mergeProcessingMode, grpc_service_ above. Can we just have similar simple logic : if most_specific has namespaces, use that; if most_specific doesn't , use less_specific.

I might have worded this poorly. This is currently the behavior. What was meant by letting the control plane handle the merge is that the if a control plane implementation has abstractions over Envoy APIs, then during the translation down to Envoy API, it is the responsibility of the control plane to ensure that the most specific config defined is the desired state of the metadata namespaces config/overrides

Copy link
Member

Choose a reason for hiding this comment

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

SGTM, Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After discussing with @tyxia I need to revisit the merge logic here to make sure nonexistent more-specific config doesn't blow out existing less-specific config

/wait

yanavlasov
yanavlasov previously approved these changes Jan 29, 2024
Copy link
Contributor

@yanavlasov yanavlasov left a comment

Choose a reason for hiding this comment

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

LGTM from me. Waiting for @tyxia final review.

/wait-any

Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
@jbohanon
Copy link
Contributor Author

/retest

@yanavlasov yanavlasov merged commit 8f95f9e into envoyproxy:main Jan 30, 2024
53 of 54 checks passed
jbohanon added a commit to solo-io/envoy-fork that referenced this pull request Feb 28, 2024
Introduce the ability to send dynamic metadata in the External Processing Request. Also implements the API for returning dynamic metadata as part of the External Processing Response.

---------

Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
jbohanon added a commit to solo-io/envoy-fork that referenced this pull request Mar 1, 2024
Introduce the ability to send dynamic metadata in the External Processing Request. Also implements the API for returning dynamic metadata as part of the External Processing Response.

---------

Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
jbohanon added a commit to solo-io/envoy-fork that referenced this pull request Mar 12, 2024
* ext_proc: send attributes (envoyproxy#31090)

Introduce the ability to send attributes in the External Processing Request

---------

Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>

* ext_proc: send and receive dynamic metadata (envoyproxy#30747)

Introduce the ability to send dynamic metadata in the External Processing Request. Also implements the API for returning dynamic metadata as part of the External Processing Response.

---------

Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>

* ext_proc: revise service api for attributes (envoyproxy#32176)


---------

Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>

---------

Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
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.

Dynamic Metadata for External Processing Filters Similar to Dynamic Metadata for External Authorization
8 participants