Skip to content

fix(policy): support xPolicies with routes referencing ListenerSet - #9243

Closed
eplightning wants to merge 2 commits into
envoyproxy:mainfrom
eplightning:feat/btp-sp-for-listenerset-routes
Closed

eplightning wants to merge 2 commits into
envoyproxy:mainfrom
eplightning:feat/btp-sp-for-listenerset-routes

Conversation

@eplightning

@eplightning eplightning commented Jun 17, 2026 •

Copy link
Copy Markdown

What type of PR is this?
feature

What this PR does / why we need it:
Adds support for using BackendTrafficPolicy, EnvoyExtensionPolicy and SecurityPolicy with routes that reference a ListenerSet in their parentRefs. Currently, such policies are ignored.

Which issue(s) this PR fixes:
Fixes #9242

Release Notes: Yes

@eplightning
eplightning requested a review from a team as a code owner June 17, 2026 14:38
@netlify

netlify Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit ea9b7d3
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6a3b2fc6e35007000813f50a
😎 Deploy Preview https://deploy-preview-9243--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b17b1caea3

ℹ️ 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".

Comment thread internal/gatewayapi/securitypolicy.go Resolved
@eplightning

eplightning commented Jun 17, 2026 •

Copy link
Copy Markdown
Author

I think this might break if gateway and listenerset listeners have duplicate names, gonna look at this again later.

Was a behavior unrelated to this PR.

@eplightning
eplightning marked this pull request as draft June 17, 2026 15:34
@eplightning
eplightning force-pushed the feat/btp-sp-for-listenerset-routes branch from b17b1ca to fc57479 Compare June 17, 2026 22:00
@eplightning
eplightning marked this pull request as ready for review June 17, 2026 22:03
@eplightning eplightning changed the title feat(policy): support BackendTrafficPolicy and SecurityPolicy with routes referencing ListenerSet feat(policy): support policies with routes referencing ListenerSet Jun 17, 2026
@eplightning eplightning changed the title feat(policy): support policies with routes referencing ListenerSet feat(policy): support xPolicies with routes referencing ListenerSet Jun 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc57479cdb

ℹ️ 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".

Comment thread internal/gatewayapi/helpers.go Resolved
@codecov

codecov Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.20%. Comparing base (24f883f) to head (ea9b7d3).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9243      +/-   ##
==========================================
+ Coverage   75.17%   75.20%   +0.02%     
==========================================
  Files         252      252              
  Lines       41049    41060      +11     
==========================================
+ Hits        30860    30879      +19     
+ Misses       8093     8086       -7     
+ Partials     2096     2095       -1     

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zhaohuabing zhaohuabing changed the title feat(policy): support xPolicies with routes referencing ListenerSet fix(policy): support xPolicies with routes referencing ListenerSet Jun 18, 2026
@eplightning
eplightning force-pushed the feat/btp-sp-for-listenerset-routes branch from 3bd3d04 to 806205f Compare June 19, 2026 07:43
@zhaohuabing

Copy link
Copy Markdown
Member

It seems that this PR breaks the ProxyProtocol e2e test.

@zhaohuabing

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 806205fda9

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Name: string(p.Name),
Namespace: namespace,
Name: gwCtx.Name,
Namespace: gwCtx.Namespace,
},
SectionName: ptr.Deref(p.SectionName, ""),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Record ListenerSet routes under their actual listeners

When the route parentRef is a ListenerSet without a sectionName, p.SectionName is empty even though the route is only attached to the resolved ListenerSet listeners. Storing that route under the Gateway-wide "" section makes the later overridden-status calculation treat this route policy as overriding every listener policy on the parent Gateway, including native Gateway listeners that the route never selected; the same mapping pattern is present in the EnvoyExtensionPolicy and SecurityPolicy changes. Use the resolved parentRefCtx.listeners or an LS-specific key instead of the raw parentRef section for ListenerSet parents.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm not sure what's the right way to do this for ListenerSets honestly, iterating over all listeners and adding all of them to the map?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like the approach in #9270 - it tackles this by not reusing the Gateway SectionName == "" route map for ListenerSet parents. It replaces that with an explicit policy-scope graph.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I agree that its a much more cleaner approach.

There's a bit of overlap with this PR, and it also seems to fix the same thing - but only for the SecurityPolicy.

Should I wait for that PR to land? Or just remove the SecurityPolicy part for now to avoid overlap.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @eplightning, thanks for working on this! And sorry for the conflicting work.

To reduce the reviewer’s workload, I intentionally limited the scope of #9270 to SecurityPolicy only.
But I plan to apply the same changes to all xPolicies after merging #9270.

Would it be okay to proceed with applying this approach to all policies on my side?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@kkk777-7 Yes that's perfectly fine with me, thank you for working on this.

@eplightning
eplightning force-pushed the feat/btp-sp-for-listenerset-routes branch from 806205f to 28a33ac Compare June 22, 2026 08:40
@eplightning

Copy link
Copy Markdown
Author

It seems that this PR breaks the ProxyProtocol e2e test.

I couldn't reproduce locally with make e2e, maybe the rebase helped or it was some flake?

@eplightning
eplightning force-pushed the feat/btp-sp-for-listenerset-routes branch from 28a33ac to 1aa4ff8 Compare June 22, 2026 11:29
@eplightning

Copy link
Copy Markdown
Author

Sorry, had to rerun make testdata to update test files with the new lua filterContext fields

@zhaohuabing

Copy link
Copy Markdown
Member

/retest

@jukie

jukie commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea9b7d31db

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +684 to +690
return gwapiv1.ParentReference{
Group: GroupPtr(gwapiv1.GroupName),
Kind: KindPtr(kind),
Namespace: namespace,
Name: routeParentCtx.Name,
SectionName: routeParentCtx.SectionName,
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve port-scoped ListenerSet ancestors

When a route selects a ListenerSet listener with parentRefs[].port and no sectionName (like the new httproute-2 fixture), this newly-created ancestor ref drops routeParentCtx.Port, so multiple parentRefs to the same ListenerSet on different ports collapse into one PolicyAncestorStatus and any per-attachment conditions can be misattributed. Please carry the port through here (and match it when comparing ancestor refs) so port-scoped ListenerSet attachments get distinct status.

Useful? React with 👍 / 👎.

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.

Support using xPolicies with routes that attach to ListenerSets

4 participants