Repository navigation
feat: support listenerset policy attach in security policy - #9270
Conversation
✅ Deploy Preview for cerulean-figolla-1f9435 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9270 +/- ##
==========================================
+ Coverage 75.19% 75.32% +0.13%
==========================================
Files 252 252
Lines 41093 41434 +341
==========================================
+ Hits 30900 31212 +312
- Misses 8090 8110 +20
- Partials 2103 2112 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
116c8a3 to
fc7411a
Compare
Signed-off-by: kkk777-7 <[email protected]>
Signed-off-by: kkk777-7 <[email protected]>
Signed-off-by: kkk777-7 <[email protected]>
0dee788 to
47f3548
Compare
Signed-off-by: kkk777-7 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc8b8e6127
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| overrides.RegisterListenerSet(parentNN, parentGwNN) | ||
|
|
||
| // Register section name to Gateway index for efficient lookup when retrieving overridden and merged targets | ||
| if _, ok := gatewayRouteMap.SectionIndex[mapKey.NamespacedName]; !ok { |
There was a problem hiding this comment.
this building map logic moves policyGraph's Add method.
| // +kubebuilder:validation:XValidation:rule="has(self.targetRefs) ? self.targetRefs.all(ref, ref.group == 'gateway.networking.k8s.io') : true ", message="this policy can only have a targetRefs[*].group of gateway.networking.k8s.io" | ||
| // +kubebuilder:validation:XValidation:rule="has(self.targetRefs) ? self.targetRefs.all(ref, ref.kind in ['Gateway', 'HTTPRoute', 'GRPCRoute', 'TCPRoute']) : true ", message="this policy can only have a targetRefs[*].kind of Gateway/HTTPRoute/GRPCRoute/TCPRoute" | ||
| // +kubebuilder:validation:XValidation:rule="has(self.targetRefs) ? self.targetRefs.all(ref, ref.kind in ['Gateway', 'ListenerSet', 'HTTPRoute', 'GRPCRoute', 'TCPRoute']) : true ", message="this policy can only have a targetRefs[*].kind of Gateway/ListenerSet/HTTPRoute/GRPCRoute/TCPRoute" | ||
| // +kubebuilder:validation:XValidation:rule="!has(self.mergeType) || ((!has(self.targetRef) || self.targetRef.kind in ['HTTPRoute', 'GRPCRoute', 'TCPRoute']) && (!has(self.targetRefs) || self.targetRefs.all(ref, ref.kind in ['HTTPRoute', 'GRPCRoute', 'TCPRoute'])) && (!has(self.targetSelectors) || self.targetSelectors.all(sel, sel.kind in ['HTTPRoute', 'GRPCRoute', 'TCPRoute'])))", message="mergeType can only be used with xRoute targets" |
There was a problem hiding this comment.
Add cel validation for mergeType.
Users who had set mergeType on a Policy targeting a Gateway will no longer be able to configure it. However, since we had already documented that mergeType is intended only for Route targets, I think this validation can be added without issue.
Signed-off-by: kkk777-7 <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
There was a problem hiding this comment.
Pull request overview
Adds first-class ListenerSet targeting support to SecurityPolicy, including precedence/override semantics and route policy behavior when routes attach via ListenerSet. This extends the policy-attachment surface area in internal/gatewayapi and tightens admission validation around mergeType.
Changes:
- Allow
SecurityPolicytargetRef(s)to referenceListenerSet(andsectionNamewithin a ListenerSet) and implement attachment/override logic in the Gateway API translator. - Extend route policy processing to correctly resolve parents/ancestors and merge behavior when a route is attached through a
ListenerSet. - Add/refresh CEL validation tests, e2e coverage, docs, generated CRDs/helm outputs, and release notes for the new targeting and stricter
mergeTypeconstraints.
Reviewed changes
Copilot reviewed 28 out of 30 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/helm/gateway-crds-helm/envoy-gateway-crds.out.yaml | Updates rendered CRD output to allow ListenerSet targets and adds mergeType xRoute-only validation. |
| test/helm/gateway-crds-helm/e2e.out.yaml | Same CRD output updates for e2e helm snapshot. |
| test/helm/gateway-crds-helm/all.out.yaml | Same CRD output updates for combined helm snapshot. |
| test/e2e/tests/utils.go | Adds an e2e helper to wait for Overridden=True on SecurityPolicy ancestors. |
| test/e2e/tests/securitypolicy_listenerset.go | New e2e conformance test covering ListenerSet-targeted policies and ListenerSet-attached routes. |
| test/e2e/testdata/securitypolicy-listenerset.yaml | New e2e manifests exercising ListenerSet policy attachment, route attachment, and merge behavior. |
| test/cel-validation/securitypolicy_test.go | Extends CEL admission tests for ListenerSet targets and mergeType xRoute-only restrictions. |
| site/content/en/latest/concepts/gateway_api_extensions/security-policy.md | Documents ListenerSet targeting semantics, precedence, and merge hierarchy with ListenerSets. |
| site/content/en/latest/api/extension_types.md | Updates generated API reference to list ListenerSet as a supported target and reflects mergeType constraints. |
| release-notes/current.yaml | Adds breaking-change note for stricter mergeType validation and a new-feature note for ListenerSet targets. |
| internal/gatewayapi/validate.go | Adds validation for ListenerSet listener sectionName existence. |
| internal/gatewayapi/testdata/tcproute-securitypolicy-with-authorization-client-cidr.out.yaml | Updates expected status message formatting to include fully-qualified “gateway listeners” wording. |
| internal/gatewayapi/testdata/securitypolicy-route-listenerset.out.yaml | New golden output covering route policy status/IR when route attaches via ListenerSet. |
| internal/gatewayapi/testdata/securitypolicy-route-listenerset.in.yaml | New input for the ListenerSet-attached-route SecurityPolicy scenario. |
| internal/gatewayapi/testdata/securitypolicy-override-replace.out.yaml | Updates expected overridden message formatting (“gateway listeners: ...”). |
| internal/gatewayapi/testdata/securitypolicy-listenerset.out.yaml | New golden output covering ListenerSet-targeted policies. |
| internal/gatewayapi/testdata/securitypolicy-listenerset.in.yaml | New input for ListenerSet-targeted SecurityPolicy tests. |
| internal/gatewayapi/testdata/securitypolicy-listenerset-same-name-listeners.out.yaml | New golden output for same-name listener disambiguation across Gateway vs ListenerSet. |
| internal/gatewayapi/testdata/securitypolicy-listenerset-same-name-listeners.in.yaml | New input for same-name listener disambiguation scenario. |
| internal/gatewayapi/testdata/securitypolicy-listenerset-merge.out.yaml | New golden output for merge behavior when routes attach through ListenerSets. |
| internal/gatewayapi/testdata/securitypolicy-listenerset-merge.in.yaml | New input for ListenerSet-aware merge behavior. |
| internal/gatewayapi/testdata/securitypolicy-listenerset-invalid.out.yaml | New golden output for invalid/conflicting ListenerSet SecurityPolicy targeting cases. |
| internal/gatewayapi/testdata/securitypolicy-listenerset-invalid.in.yaml | New input for invalid/conflicting ListenerSet targeting cases. |
| internal/gatewayapi/securitypolicy.go | Implements ListenerSet policy targeting, route-parent resolution via ListenerSet, and override/merge tracking via scope graph. |
| internal/gatewayapi/securitypolicy_test.go | Updates unit tests to use new ListenerSet-aware route processing signature. |
| internal/gatewayapi/helpers.go | Introduces ListenerSet policy target context, policy-scope graph helpers, and ListenerSet targeting predicates. |
| internal/gatewayapi/helpers_test.go | Adds unit coverage for the new policy-scope graph traversal behavior. |
| charts/gateway-helm/charts/crds/crds/generated/gateway.envoyproxy.io_securitypolicies.yaml | Updates generated CRD to allow ListenerSet and enforce mergeType xRoute-only usage. |
| charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_securitypolicies.yaml | Same CRD updates for the CRDs helm chart template. |
| api/v1alpha1/securitypolicy_types.go | Updates API type docs/validations to include ListenerSet targets and mergeType xRoute-only validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: kkk777-7 <[email protected]>
Signed-off-by: kkk777-7 <[email protected]>
Signed-off-by: kkk777-7 <[email protected]>
Signed-off-by: kkk777-7 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd517ea01f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: kkk777-7 <[email protected]>
zhaohuabing
left a comment
There was a problem hiding this comment.
LGTM. Love the clean solution!
Signed-off-by: kkk777-7 <[email protected]>
|
/retest |
…dant test The *p.Kind == resource.KindListenerSet block in processSecurityPolicyForRoute now uses the same early-continue guard pattern as processBackendTrafficPolicyForRoute and processEnvoyExtensionPolicyForRoute: - check parentRefCtx == nil → continue - check GetGateway() == nil → TargetNotFound + continue - append to parentRefCtxs The securitypolicy-with-merge-listenerset-route test fixtures are removed: PR envoyproxy#9270 already covers StrategicMerge with ListenerSet-attached routes via the securitypolicy-listenerset-merge test (7 policy scenarios). Signed-off-by: Emile <[email protected]>
|
May fix #9409 |
What this PR does / why we need it:
Support policy attachment for ListenerSet.
This PR includes:
currently, don't support
mergeTypefor ListenerSet. only support for xRoute.Which issue(s) this PR fixes:
Fixes #8092 (needs follow up PRs for another policies)
Release Notes: Yes