Skip to content

fix(translator): name merged cluster stats after the backend - #10631

Merged
zhaohuabing merged 6 commits into
envoyproxy:mainfrom
zhaohuabing:fix-merged-cluster-stat-name
Nov 19, 2026
Merged

zhaohuabing merged 6 commits into
envoyproxy:mainfrom
zhaohuabing:fix-merged-cluster-stat-name

Conversation

@zhaohuabing

@zhaohuabing zhaohuabing commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Fixes #9570

When clusterStatName is set, a cluster shared through mergeBackends now gets an alt_stat_name of <namespace>/<name> after its backend, instead of none. Route operators in the pattern can't be resolved for a cluster that several routes share, so the pattern itself isn't applied.

  • <namespace>/<name> is what the %BACKEND_REFS% operator expands to for a rule with one backendRef, so the common "aggregate stats per backend" setup keeps the same stat names after turning on merging.
  • Unmerged clusters still use the full pattern, and nothing changes when clusterStatName is unset.
  • No new API. As discussed in api: merge backend cluster alt stat #10021, a dedicated field for merged cluster stat names can come later and default to this value.

Merged backend clusters dropped clusterStatName entirely, so their stats fell back to the
generated cluster name. When clusterStatName is set, a merged cluster now gets an
alt_stat_name of <namespace>/<name>, the same value %BACKEND_REFS% gives a single-backend
rule. A future API for merged cluster stat names can default to this.

Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
@netlify

netlify Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

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

Built without sensitive environment variables

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

Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
@github-actions github-actions Bot added the area/api API-related issues label Nov 17, 2026
@zhaohuabing
zhaohuabing marked this pull request as ready for review November 17, 2026 08:43
@zhaohuabing
zhaohuabing requested a review from a team as a code owner November 17, 2026 08:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T05:57:16.491166Z 482b324 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.

The old wording could be read as the default stat name. It's the value the %BACKEND_REFS%
operator expands to for a rule with one backendRef.

Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
@zhaohuabing
zhaohuabing requested a review from kkk777-7 November 17, 2026 08:51
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.85%. Comparing base (199cbd3) to head (482b324).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10631      +/-   ##
==========================================
+ Coverage   82.84%   82.85%   +0.01%     
==========================================
  Files         278      278              
  Lines       44597    44601       +4     
==========================================
+ Hits        36945    36953       +8     
+ Misses       7651     7647       -4     
  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
kkk777-7 previously approved these changes Nov 17, 2026
@kkk777-7

Copy link
Copy Markdown
Member

LGTM, thanks!

@zhaohuabing
zhaohuabing requested a review from a team November 17, 2026 09:50

// irBackendClusterStatName names a BackendCluster's stats after its backend, in the same
// <namespace>/<name> format that %BACKEND_REFS% uses.
func irBackendClusterStatName(key *BackendClusterKey) string {

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.

do we need GVK here?

@zhaohuabing zhaohuabing Nov 19, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

With merging off, clusterStatName: %BACKEND_REFS% names a single-backend cluster <namespace>/<name> with no kind. Using the same format for merged clusters means that setup keeps its stat names after turning on merging. If we need finer names, it could be an opt-in operator.

@zirain zirain Nov 19, 2026 •

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.

we could add %BACKEND_KIND% or %BACKEND_GVK% later.

Note in the comment that a Service and a Backend sharing a name in one
namespace is rare, so the kind isn't worth longer stat names. A new
operator can add it later if needed.

Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[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: 482b324bf2

ℹ️ 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 +1038 to +1039
if statName != nil && backendCluster.StatName == nil {
backendCluster.StatName = new(irBackendClusterStatName(bd.backendClusterKey))

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 Keep route-based stats for single-use merged clusters

When MergeBackends is enabled for an eligible backend referenced by only one route or rule, this still replaces the configured clusterStatName pattern with namespace/name, even though the route operators are unambiguous. Because processBackendRef creates a BackendCluster for every eligible reference, not only references that are actually deduplicated, enabling merging silently changes metric names for single-use backends too. Limit this fallback to clusters shared across routes, or retain the route stat name for single-use clusters.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is intentional. Keeping route-based names for single-use clusters would rename a route's stats whenever another route starts or stops using the same backend. Naming merged clusters after the backend keeps them stable.

@zhaohuabing
zhaohuabing merged commit 1b01592 into envoyproxy:main Nov 19, 2026
49 checks passed
@zhaohuabing
zhaohuabing deleted the fix-merged-cluster-stat-name branch November 19, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API-related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merging backends drops alt_stat_name (EnvoyProxy clusterStatName) for merged clusters

3 participants