Repository navigation
fix(translator): name merged cluster stats after the backend - #10631
Conversation
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]>
✅ Deploy Preview for cerulean-figolla-1f9435 ready!Built without sensitive environment variables
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]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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]>
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
LGTM, thanks! |
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
|
|
||
| // irBackendClusterStatName names a BackendCluster's stats after its backend, in the same | ||
| // <namespace>/<name> format that %BACKEND_REFS% uses. | ||
| func irBackendClusterStatName(key *BackendClusterKey) string { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]>
There was a problem hiding this comment.
💡 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".
| if statName != nil && backendCluster.StatName == nil { | ||
| backendCluster.StatName = new(irBackendClusterStatName(bd.backendClusterKey)) |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
Fixes #9570
When
clusterStatNameis set, a cluster shared throughmergeBackendsnow gets analt_stat_nameof<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.clusterStatNameis unset.