Skip to content

Feat: Extension server policy propagation to PostTranslateModify#5914

Merged
guydc merged 4 commits intoenvoyproxy:mainfrom
imesh-ai:allow-extension-policy-in-post-translate-hook
Jun 7, 2025
Merged

Feat: Extension server policy propagation to PostTranslateModify#5914
guydc merged 4 commits intoenvoyproxy:mainfrom
imesh-ai:allow-extension-policy-in-post-translate-hook

Conversation

@raviverma-ai
Copy link
Contributor

What type of PR is this?

  • "feat(translator): Add extension server policies to PostTranslateContext so that extension server can take actions accordingly."

What this PR does / why we need it:
Add custom extension server policies to PostTranslateContext and eventually pass to PostTranslateModify() method so that extension server can take actions accordingly based on CRDs.

Release Notes: Yes

@raviverma-ai raviverma-ai requested a review from a team as a code owner May 4, 2025 02:35
@arkodg arkodg requested a review from guydc May 5, 2025 21:39
@raviverma-ai raviverma-ai changed the title Extension server policy propagation to PostTranslateModify Feat: Extension server policy propagation to PostTranslateModify May 8, 2025
@codecov
Copy link

codecov bot commented May 27, 2025

Codecov Report

Attention: Patch coverage is 88.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 70.49%. Comparing base (e07d1ec) to head (48d054b).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
internal/extension/registry/xds_hook.go 80.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5914      +/-   ##
==========================================
- Coverage   70.52%   70.49%   -0.04%     
==========================================
  Files         220      220              
  Lines       36621    36639      +18     
==========================================
  Hits        25828    25828              
- Misses       9268     9285      +17     
- Partials     1525     1526       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@guydc guydc left a comment

Choose a reason for hiding this comment

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

Can we avoid saving the extension policies twice per XDS? they are saved for both the entire XDS and the IR Listener now.

@arkodg
Copy link
Contributor

arkodg commented May 28, 2025

hey @raviverma-ai can you share your use case, curious why the other hooks aren't applicable

@guydc
Copy link
Contributor

guydc commented May 28, 2025

cc @nareddyt

@muwaqar
Copy link

muwaqar commented May 28, 2025

this seems to be doing what I suggested in #5561, but it would be good to know what the specific use-case for the PR author is (as arko said here: #5914 (comment))

@raviverma-ai
Copy link
Contributor Author

raviverma-ai commented May 28, 2025

hey @raviverma-ai can you share your use case, curious why the other hooks aren't applicable

@arkodg, @muwaqar

This enables users to perform actions which needs modifications to clusters (other hooks are not proving options to modify clusters). In our particular use case, we would like to enable sds based mtls certificate issuance and rotation instead of manually updating certificates. This requires clusters to have UpstreamTlsContext pointing to sds server and get certificates automatically. In our case, we are creating native integration with Istio and to avoid sidecar injection on EG.

@arkodg
Copy link
Contributor

arkodg commented May 28, 2025

thanks @raviverma-ai, the use case makes sense, do you need access to Extension Resources for this case ?

@arkodg arkodg added this to the v1.5.0-rc.1 Release milestone May 28, 2025
@raviverma-ai
Copy link
Contributor Author

@arkodg, Yes, it would give more control to user to take actions on. For instance, we are using extension server policy CRD to enable this feature bound to specific gateway. i.e. If user wants to enable sds based mtls for specific gateway and not for all gateways. Furthermore, we are planning to provide even more control in future like user would be able to control this behaviour on httproute or backend/service basis (still under discussion for feasibility and use case).

@raviverma-ai raviverma-ai force-pushed the allow-extension-policy-in-post-translate-hook branch from 33ad861 to c070bd2 Compare May 29, 2025 08:41
@arkodg arkodg requested review from a team and guydc May 30, 2025 20:11
@raviverma-ai raviverma-ai force-pushed the allow-extension-policy-in-post-translate-hook branch 3 times, most recently from cdcf7fc to ec030bc Compare June 3, 2025 08:26
@guydc
Copy link
Contributor

guydc commented Jun 3, 2025

hi @raviverma-ai. Thoughts on this comment from earlier?

Can we avoid saving the extension policies twice per XDS? they are saved for both the entire XDS and the IR Listener now.

@guydc
Copy link
Contributor

guydc commented Jun 3, 2025

cc @liorokman

@raviverma-ai
Copy link
Contributor Author

hi @raviverma-ai. Thoughts on this comment from earlier?

Can we avoid saving the extension policies twice per XDS? they are saved for both the entire XDS and the IR Listener now.

@guydc thanks for reminding. Updated logic to store the pointer to original policies instead of creating another copy.

@guydc
Copy link
Contributor

guydc commented Jun 3, 2025

@guydc thanks for reminding. Updated logic to store the pointer to original policies instead of creating another copy.

I think that this should be reflected in the test files as well. Can you regenerate the test output files with make go.testdata.complete so that we can see the impact?

Also, please add a few test cases for this new flow to internal/xds/testdata/extension-xds-ir and extend testingExtensionServer to have some logic to cover:

  • Creation of new secrets/clusters based on extension resources
  • Emitting errors and handling them in the extension manager

@raviverma-ai raviverma-ai force-pushed the allow-extension-policy-in-post-translate-hook branch from 0d1d884 to 8d5f19b Compare June 5, 2025 14:45
@raviverma-ai
Copy link
Contributor Author

raviverma-ai commented Jun 5, 2025

@guydc thanks for reminding. Updated logic to store the pointer to original policies instead of creating another copy.

I think that this should be reflected in the test files as well. Can you regenerate the test output files with make go.testdata.complete so that we can see the impact?

Also, please add a few test cases for this new flow to internal/xds/testdata/extension-xds-ir and extend testingExtensionServer to have some logic to cover:

  • Creation of new secrets/clusters based on extension resources
  • Emitting errors and handling them in the extension manager

@guydc added/updated test cases as requested.
p.s. changes with 'make go.testdata.complete' were submitted as well.

@raviverma-ai raviverma-ai force-pushed the allow-extension-policy-in-post-translate-hook branch from 8d5f19b to 09d990a Compare June 5, 2025 16:51
…tually pass to PostTranslateModify() method

Signed-off-by: Ravi Verma <ravi@imesh.ai>
Signed-off-by: Ravi Verma <ravi@imesh.ai>
…instead of creating another copy

Signed-off-by: Ravi Verma <ravi@imesh.ai>
…r policy

Signed-off-by: Ravi Verma <ravi@imesh.ai>
@raviverma-ai raviverma-ai force-pushed the allow-extension-policy-in-post-translate-hook branch from 09d990a to 48d054b Compare June 5, 2025 16:53
@guydc
Copy link
Contributor

guydc commented Jun 5, 2025

@raviverma-ai - one question on my end. Right now, for gateway-attached policies, we save the relevant policy for the appropriate listener in the gateway and provide it as context in that listener's scope.

Here, we seem to store all policies on the gateway level and send them as context for the post-translate hook. As a user, does that meet your requirements? Do you not need to know which specific clusters (originating from specific listeners) should be affected by the policy?

@raviverma-ai
Copy link
Contributor Author

@guydc As I had mentioned earlier as well. For this or any similar use case, where user only needs to know which Gateway, that specific Extension Server Policy is applicable to, i.e. all dynamic cluster can be modified/reviewed or even specific ones as well, those information can be specified in Custom Extension Server Policy defined by user. For now, we will be using this to enable mtls via sds server on all backend communications. However, there is plan for future to even further fine tune and target specific route/service etc.
Hope, I was able to answer your question.

@guydc guydc requested review from guydc, muwaqar and nareddyt June 5, 2025 18:29
FilterOrder []egv1a1.FilterPosition `json:"filterOrder,omitempty" yaml:"filterOrder,omitempty"`
// GlobalResources holds the global resources used by the Envoy, for example, the envoy client certificate and the OIDC HMAC secret
GlobalResources *GlobalResources `json:"globalResources,omitempty" yaml:"globalResources,omitempty"`
// ExtensionServerPolicies is the intermediate representation of the ExtensionServerPolicy resource
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use the same naming used in other places like L264

	// ExtensionRefs holds unstructured resources that were introduced by an extension policy
	ExtensionRefs []*UnstructuredRef `json:"extensionRefs,omitempty" yaml:"extensionRefs,omitempty"`

Copy link
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM thanks
added one non blocker comment

@guydc guydc merged commit 402cd99 into envoyproxy:main Jun 7, 2025
77 of 83 checks passed
@guydc
Copy link
Contributor

guydc commented Jun 7, 2025

@raviverma-ai

can we use the same naming used in other places like L264
// ExtensionRefs holds unstructured resources that were introduced by an extension policy
ExtensionRefs []*UnstructuredRef json:"extensionRefs,omitempty" yaml:"extensionRefs,omitempty"

Can you fix this in a follow-up PR please?

@raviverma-ai
Copy link
Contributor Author

@raviverma-ai

can we use the same naming used in other places like L264
// ExtensionRefs holds unstructured resources that were introduced by an extension policy
ExtensionRefs []*UnstructuredRef json:"extensionRefs,omitempty" yaml:"extensionRefs,omitempty"

Can you fix this in a follow-up PR please?

Yes, sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants