-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: duplicate custom resources #2066
base: main
Are you sure you want to change the base?
fix: duplicate custom resources #2066
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplication can be suppressed by specifying --custom-resources-only
flag for the native metrics, which will force KSM to generate metrics only from the CRS configuration, and which has been the supported behaviour till now for when the same (internal) object is specified under both flags.
pkg/app/server.go
Outdated
resources = append(resources, opts.Resources.AsSlice()...) | ||
resources = opts.Resources.AsSlice() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One case that satisfies the default
case is when a custom-resource-state-only
flag is not specified, and the resources
flag is non-nil. In this case if we also specify custom-resource-state-config
flag (with a CRS configuration), we'd get duplicate metrics if the entries in both overlap (for a common native resource).
resources
in the code snippet above are the extracted resources we obtain from the CRS configuration, and removing them here would result in removing the current ability for KSM to generate and serve native and custom metrics (for different objects), for instance, kube-state-metrics --kubeconfig=$KUBECONFIG --custom-resource-state-config-file=... --resources=...
.
IIUC with this change, the CRS resources extracted will be ignored entirely (for the aforementioned case), which will be a breaking change, since that's the expected behaviour ever since CRS was introduced.
Hi @rexagod . In that case would it be better to add logic to remove duplicates from the |
74c3477
to
6f7be35
Compare
Holding since I am not a fan of using custom-state-metrics as a way to hack around kube-state-metrics. I am moving the discussion back to the issue. /hold |
/triage accepted |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
pkg/app/server.go
Outdated
@@ -53,6 +53,7 @@ import ( | |||
"k8s.io/kube-state-metrics/v2/pkg/metricshandler" | |||
"k8s.io/kube-state-metrics/v2/pkg/optin" | |||
"k8s.io/kube-state-metrics/v2/pkg/options" | |||
"k8s.io/kube-state-metrics/v2/pkg/util/collections" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use sets here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@murphd40 any progress? :)
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: murphd40 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/remove-lifecycle stale |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle rotten |
…2044-duplicate-custom-resources
Hi @ikarlashov @rexagod. Apologies for the delay. I have updated the PR as suggested. However, when I run
It fails:
It is failing on It is failing at this point:
It seems that the custom resource config is no longer added to storeBuilder before this check so the store builder does not recognize it... |
Can you add a unit test that produces duplicate CRs as well? |
@murphd40 Please :) |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Is this PR still needed as #2502 got merged? |
What this PR does / why we need it:
Fix issue where custom resources are duplicated
How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)
No change
Which issue(s) this PR fixes:
Fixes # #2044
Testing:
Before change
After Change