-
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: avoid panic because of VPA objects without target ref #1584
fix: avoid panic because of VPA objects without target ref #1584
Conversation
Welcome @nabokihms! |
Awesome, thanks for catching this! I just wonder if we want to still expose a metric with an empty targetRef apiversion, kind and name in these cases. The rule of thumb is to always expose raw data and use PromQL to filter it later on. A metric with empty values could be beneficial for alerting on VPAs without a target ref. Also, not emitting a metric could break clients that have queries which count the number of VPAs per cluster, namespace, team etc.. |
Make sense. My first thoughts were about exporting resources for targets because it is our main use-case. I will do as you've said. |
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
b8ebecb
to
8579a68
Compare
Great stuff. /lgtm |
@@ -19,6 +19,7 @@ package store | |||
import ( | |||
"context" | |||
|
|||
k8sautoscaling "k8s.io/api/autoscaling/v1" |
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.
k8sautoscaling "k8s.io/api/autoscaling/v1" | |
autoscalingv1 "k8s.io/api/autoscaling/v1" |
Can we refactor this to use a similar approach like metav1 below?
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.
I copied it from the ksm code somewhere, but yes, no problem. I will make the change.
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fpetkovski, mrueg, nabokihms The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@mrueg @fpetkovski is this fix going to be backported to 2.2 and 2.1? Thanks! |
Signed-off-by: m.nabokikh maksim.nabokikh@flant.com
What this PR does / why we need it:
VPA is a custom resource. CRDs for this resource can be found there.
The problem is that the
targetRef
field was not required by the spec, so there is a possibility to deploy VPA to the cluster without it, which makes kube-state-metrics panic.Without target ref, VPA objects receive no recommendation update. It is pointless trying to expose metrics for them.
How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)
It does not change cardinality.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Did not manage to find one.