Skip to content

feat(api): add Selector to MergeBackendsConfig to restrict cluster deduplication - #9624

Open
muwaqar-cflt wants to merge 11 commits into
envoyproxy:mainfrom
muwaqar:mergebackends-selector
Open

feat(api): add Selector to MergeBackendsConfig to restrict cluster deduplication#9624
muwaqar-cflt wants to merge 11 commits into
envoyproxy:mainfrom
muwaqar:mergebackends-selector

Conversation

@muwaqar-cflt

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Adds a selector field to EnvoyProxy.spec.mergeBackends, restricting cluster deduplication to backends whose target Service or Backend resource matches a label selector. When unset, every otherwise-eligible backend is merged (today's behavior, unchanged). This lets operators opt individual backends into deduplication gradually instead of enabling it for every backend at once.

The resolved MergeBackends config (enabled + selector) is now computed once per Translator via ResolveMergeBackendsConfig, replacing the old plain bool, so shouldMergeBackend can consult both fields together with the same GatewayClass/global-default precedence, and a Gateway-level EnvoyProxy override still wins over that resolved value wholesale (not merged field-by-field).

Which issue(s) this PR fixes:

N/A - new feature request, no linked issue.


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).
  • API agreed first: N/A - additive, optional field on an existing config type; no breaking change.
  • Required checks pass: go build ./..., go vet ./..., gofmt -l, make lint.golint, and go test ./... all pass. make gen-check shows no drift beyond this PR's own changes.
  • Tests added/updated: Unit tests in helpers_test.go and route_test.go, a gateway-to-IR translator fixture, and an xds-ir translator fixture for a Selector-excluded backend.
  • Docs: Regenerated CRD reference docs (extension_types.md) and CRD YAML manifests.
  • Release notes: Added release-notes/current/new_features/mergebackends-selector.md.
  • Generated files committed: zz_generated.deepcopy.go, CRD YAML manifests, and helm-template golden fixtures regenerated and committed.
  • Scope & compatibility: Additive only; no breaking changes.
  • Codex review: Not yet requested.
  • Copilot review: Not yet requested.

@muwaqar-cflt
muwaqar-cflt requested a review from a team as a code owner July 31, 2026 02:17
@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit 1a2743d
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6a734e657a28140009efe9b0
😎 Deploy Preview https://deploy-preview-9624--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: aadc0be6c6

ℹ️ 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 Outdated
Comment thread release-notes/current/new_features/mergebackends-selector.md Outdated
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.10638% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.20%. Comparing base (aaa5569) to head (1a2743d).

Files with missing lines Patch % Lines
internal/gatewayapi/route.go 84.21% 4 Missing and 2 partials ⚠️
internal/gatewayapi/runner/runner.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9624      +/-   ##
==========================================
+ Coverage   76.19%   76.20%   +0.01%     
==========================================
  Files         261      261              
  Lines       43528    43566      +38     
==========================================
+ Hits        33164    33198      +34     
- Misses       8161     8164       +3     
- Partials     2203     2204       +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.

@muwaqar-cflt
muwaqar-cflt force-pushed the mergebackends-selector branch from aadc0be to 0b511e5 Compare July 31, 2026 02:50
@arkodg
arkodg requested review from guydc and zhaohuabing August 3, 2026 01:50
@arkodg arkodg added this to the Backlog milestone Aug 3, 2026
zhaohuabing
zhaohuabing previously approved these changes Aug 5, 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 a review from arkodg August 5, 2026 06:40
muwaqar and others added 11 commits August 5, 2026 10:32
Signed-off-by: Muhammad Waqar <waqar.hameed08@gmail.com>
Signed-off-by: Muhammad Waqar <waqar.hameed08@gmail.com>
Replace Translator.MergeBackends bool with *MergeBackendsConfig, an
internal mirror of egv1a1.MergeBackendsConfig{Enabled, Selector}, and
IsMergeBackendsEnabled with ResolveMergeBackendsConfig which resolves
both fields together using the same GatewayClass/global-default
precedence. Selector is plumbed through but not yet consulted by
shouldMergeBackend; that eligibility wiring is a follow-up.

Signed-off-by: Muhammad Waqar <waqar.hameed08@gmail.com>
…ector

Signed-off-by: Muhammad Waqar <waqar.hameed08@gmail.com>
Signed-off-by: Muhammad Waqar <waqar.hameed08@gmail.com>
…urrent IR naming

Picks up the backends->backendClusters registry rename, the dropped
backend/ cluster-name prefix, and the internal proxy-service cluster no
longer being spuriously registered as a merge candidate - all landed
on backend-cluster-dedup-rebase since this fixture was authored.

Signed-off-by: Muhammad Waqar <mwaqar@confluent.io>
Signed-off-by: Muhammad Waqar <waqar.hameed08@gmail.com>
… IR structure

The old model put every route-scoped Cluster (merged or not) under one
flat Backends list discriminated by a merged flag. Today's ir.Xds only
registers genuinely merged clusters in BackendClusters; a non-merged
backend lives inline in its route's destination.settings instead. Also
picks up the dropped backend/ cluster-name prefix.

Signed-off-by: Muhammad Waqar <mwaqar@confluent.io>
Signed-off-by: Muhammad Waqar <waqar.hameed08@gmail.com>
…rim comments

Move the nil-selector short-circuit out of mergeBackendsSelectorMatches
into its caller - a selector-match function returning true for "no
selector" was confusing. Fix the Selector doc comment to also mention
ServiceImport, which the matching code already supported. Trim a few
over-explained/history-narrating comments down to repo convention.

Signed-off-by: Muhammad Waqar <mwaqar@confluent.io>
…go-control-plane bump

Rebasing onto main picked up a go-control-plane dependency bump that
added an explicit initialFetchTimeout default to RDS ConfigSource,
which this branch's fixture predates.

Signed-off-by: Muhammad Waqar <mwaqar@confluent.io>
@zhaohuabing
zhaohuabing requested a review from a team August 6, 2026 03:10
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.

4 participants