Skip to content

api: backend priority filter - #10027

Merged
kkk777-7 merged 3 commits into
envoyproxy:mainfrom
kkk777-7:api-backend-priority
Oct 5, 2026
Merged

kkk777-7 merged 3 commits into
envoyproxy:mainfrom
kkk777-7:api-backend-priority

Conversation

@kkk777-7

@kkk777-7 kkk777-7 commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

What this PR does / why we need it:

Adds backendPriority field to HTTPRouteFilter. This PR only adds the API.

It sets the Envoy locality priority (LocalityLbEndpoints.priority) of the backendRef it is attached to, so a route rule can fail over across more than two tiers and each route can order the same backends differently.
Today Backend.spec.fallback is the only way to set a priority. It is a bool, it lives on the Backend rather than on the backendRef, and it cannot be used with Service backendRefs.

  • Filter instead of a field on Backend. Priority describes how backendRefs relate within a rule, like weight, not a property of the backend. A field on Backend would require duplicate Backend objects whenever one backend is primary on one route and a fallback on another, and it cannot cover Service backendRefs.

Which issue(s) this PR fixes:

Fixes #
Related #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 September 15, 2026 01:56
@netlify

netlify Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 61de73e
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6aba34f3dc11470008f75a14
😎 Deploy Preview https://deploy-preview-10027--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: ba70f686f7

ℹ️ 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 api/v1alpha1/httproutefilter_types.go Resolved
@codecov

codecov Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.43%. Comparing base (2de3ea6) to head (61de73e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10027   +/-   ##
=======================================
  Coverage   81.42%   81.43%           
=======================================
  Files         266      266           
  Lines       41300    41300           
=======================================
+ Hits        33630    33633    +3     
+ Misses       7669     7666    -3     
  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.

@kkk777-7

Copy link
Copy Markdown
Member Author

/retest

@kkk777-7 kkk777-7 added this to the v1.10.0-rc.1 Release milestone Sep 15, 2026
zhaohuabing
zhaohuabing previously approved these changes Sep 15, 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
zhaohuabing requested review from a team and arkodg September 15, 2026 08:20
Comment thread api/v1alpha1/httproutefilter_types.go Resolved
@kkk777-7

kkk777-7 commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

/retest

@kkk777-7
kkk777-7 merged commit 9570ff0 into envoyproxy:main Oct 5, 2026
73 of 75 checks passed
@kkk777-7
kkk777-7 deleted the api-backend-priority branch October 5, 2026 16:08
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.

3 participants