Skip to content

feat(translator): implement backendPriority HTTPRouteFilter - #10248

Merged
kkk777-7 merged 6 commits into
envoyproxy:mainfrom
kkk777-7:feat-backend-priority-filter
Oct 25, 2026
Merged

kkk777-7 merged 6 commits into
envoyproxy:mainfrom
kkk777-7:feat-backend-priority-filter

Conversation

@kkk777-7

@kkk777-7 kkk777-7 commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

What this PR does / why we need it:

Implements #10007. (API PR was merged #10027)
When the filter is referenced from HTTPBackendRef.filters, it sets the Envoy locality priority of that backendRef's endpoints, enabling multi-tier, per-route priority failover between the backendRefs of a rule.

Notes

  • Priority failover only works while a rule's backendRefs share one cluster. When the rule is split into weighted clusters for another reason (FQDN mixed with IP endpoints, backendRef filters other than backendPriority, mixed upstream protocols, mixed auto SNI, PreferLocal/WeightedZones, invalid backendRefs), the priority is still set but has no effect. Backend.spec.fallback has the same limitation today. Detecting and reporting these combinations is left to a follow-up.

Which issue(s) this PR fixes:

Fixes #10007


PR Checklist

  • Authorship & ownership: Coding agents / AI assistants are welcome, but I have reviewed every change, understand how and why it works, can explain and maintain it, and take full responsibility for this PR. I have not submitted generated output I do not understand.
  • DCO: All commits are signed off (git commit -s). See DCO: Sign your work.
  • API agreed first: If this PR contains API changes (changes under /api), the API was discussed and agreed before the implementation. The API change can be in a separate PR, or in the same PR, but the API must be agreed before implementation. N/A if this PR does not contain API changes.
  • Required checks pass: make generate gen-check, make lint, and the unit-test/coverage build pass. (Flaky e2e failures are not considered breakages, but gen-check, lint, and coverage MUST pass.)
  • Tests added/updated: New/changed code is covered by appropriate tests. N/A if this PR does not contain code changes.
  • Docs: User-facing changes update the docs, either in this PR or a follow-up PR. N/A if this PR does not contain user-facing changes.
  • Release notes: For any non-trivial change, added a release-note fragment under release-notes/current/<section>/<pr-number>-<slug>.md (see release-notes/current/README.md for sections and naming). N/A if this PR does not contain non-trivial changes.
  • Generated files committed: Ran make gen-check and committed the result if API/helm charts/modules changed.
  • Scope & compatibility: The PR is reasonably scoped (no unrelated changes) and preserves backward compatibility, or any breaking change is called out above and documented in release-notes/current/breaking_changes/.
  • Codex review: Requested a Codex review and addressed all of its comments.
  • Copilot review: Requested a Copilot review and addressed all of its comments.

@kkk777-7
kkk777-7 requested a review from a team as a code owner October 11, 2026 13:44
@netlify

netlify Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 37b84e8
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6ada13b3ce8b009c0f531e71
😎 Deploy Preview https://deploy-preview-10248--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 commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-22T13:46:44.016185Z 37b84e8 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Signed-off-by: kkk777-7 <[email protected]>

@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: 3abe7bcfe1

ℹ️ 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/filters.go Resolved
Comment thread internal/gatewayapi/route.go Resolved
@codecov

codecov Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.88%. Comparing base (e32a1b9) to head (37b84e8).

Files with missing lines Patch % Lines
internal/gatewayapi/route.go 91.30% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10248      +/-   ##
==========================================
+ Coverage   81.81%   81.88%   +0.06%     
==========================================
  Files         268      268              
  Lines       42376    42429      +53     
==========================================
+ Hits        34669    34741      +72     
+ Misses       7706     7687      -19     
  Partials        1        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.

Signed-off-by: kkk777-7 <[email protected]>
@kkk777-7

Copy link
Copy Markdown
Member Author

@codex

@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: d26ee93369

ℹ️ 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/filters.go Resolved
@kkk777-7
kkk777-7 marked this pull request as draft October 11, 2026 15:27
@kkk777-7

Copy link
Copy Markdown
Member Author

@codex

@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: d26ee93369

ℹ️ 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/route.go Resolved
@kkk777-7

Copy link
Copy Markdown
Member Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: d26ee93369

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

@zirain

zirain commented Oct 22, 2026

Copy link
Copy Markdown
Member

@kkk777-7 can you fix the conflict?

@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: 0f8a496cc5

ℹ️ 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/filters.go Resolved
zhaohuabing
zhaohuabing previously approved these changes Oct 22, 2026

@zhaohuabing zhaohuabing left a comment

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.

LGTM. Thanks!

@zhaohuabing

Copy link
Copy Markdown
Member

Non-blocking, fine as a follow-up. When something else splits the rule into weighted clusters, for example a RequestHeaderModifier on the secondary backendRef, the priority has no effect but the route still shows Accepted=True. A status condition for that case would make it easier to debug.

@zhaohuabing
zhaohuabing requested a review from a team October 22, 2026 13:20
@kkk777-7
kkk777-7 merged commit 364fcc5 into envoyproxy:main Oct 25, 2026
47 checks passed
nacx added a commit to theagentrouter/agent-router that referenced this pull request Nov 27, 2026
…3094)

**Description**

`AIGatewayRouteRuleBackendRef.priority` was invisible to Envoy Gateway:
the extension server rewrote LocalityLbEndpoints.priority in
`PostTranslateModify`, and the controller stamped
`gateway.envoyproxy.io/backend-ref-priority` annotation on every
generated HTTPRoute to force re-translation. EG copies that annotation
into the metadata of every route and cluster, which inflates xDS, and EG
could not see the priority, so MergeBackends split prioritized
rules into separate clusters and broke failover.

This uses the backendPriority HTTPRouteFilter added in EG v1.10 instead:
- For each backendRef with a non-zero priority, reference a shared
per-namespace HTTPRouteFilter (ai-eg-backend-priority-<n>). Priority 0
gets no filter, which keeps rules without priorities eligible for
MergeBackends.
- The filters are labeled managed-by and are not owned by any
AIGatewayRoute. A filter is deleted once no AIGatewayRoute in the
namespace uses its priority, which is looked up through a new
AIGatewayRoute field index. A filter that is deleted out of band is
recreated on the next reconcile.

**Related Issues/PRs (if applicable)**
Fixes #2915
Related PR: envoyproxy/gateway#10027 (backendPriority API),
envoyproxy/gateway#10248 (implementation)

**Special notes for reviewers (if applicable)**

Migration:
- The extension server rewrite is kept for one release (to be removed in
v1.5) so that HTTPRoutes generated by the previous version keep their
priorities until they are reconciled. It logs when it changes the
priority EG set, so it can be confirmed unused before removal.
- A non-zero priority overrides the Backend's spec.fallback. Priority 0
no longer does, so fallback: true on a Backend now takes effect.

**E2E on Envoy Gateway v1.9.3 skips `TestTrafficSplittingFallback` and
`Test_Examples_StreamIdleTimeout`.**
Both rely on backendRef priority failover. The CI matrix still runs e2e
on EG v1.9.3, which has no
`backendPriority`: the CRD prunes the field, and any backendRef filter
makes EG build one cluster per
backendRef of the rule, so the backendRefs end up behind
`weighted_clusters` and do not fail over. v1.9 is
below the minimum EG version (v1.10.0) in the compatibility matrix, so
these tests are skipped there via
`e2elib.EnvoyGatewaySupportsBackendPriority`, like the other
version-gated e2e tests. Agent Router
v1.2.x / v1.3.x keep the previous mechanism and are not affected.

**Shared filters instead of per-route ones.** 
EG scans `resources.HTTPRouteFilters` linearly for each reference, so
the filters are shared per namespace and priority (at most 128 per
namespace) rather than created per AIGatewayRoute. As with the shared
MCP proxy Backend (`ensureMCPProxyBackend`), they have no owner and are
not watched.

---------

Signed-off-by: kkk777-7 <[email protected]>
Co-authored-by: Ignasi Barrera <[email protected]>
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 per-backendRef locality priority (multi-tier failover) via HTTPRouteFilter

3 participants