-
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
Allow Lease metrics to be exported across all namespaces #1845
Conversation
|
Welcome @lantingchiang! |
Thanks for this PR. The change makes sense to me, but I am just curious why KSM was exporting lease metrics from that single namespace only. /lgtm |
Looking at the tests, we don't expose the namespace yet: https://github.com/kubernetes/kube-state-metrics/blob/master/internal/store/lease_test.go#L57-L58 We should update the lease store to export the fields that you added to the docs, and update tests accordingly. |
39b3045
to
5464a9d
Compare
I think it's because that namespace contains all node leases, so it was sufficient if pod leases weren't of interest. |
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.
Thanks
/lgtm
Hi @dgrisonnet, could I get a review please? Thanks! |
Exported |
internal/store/lease.go
Outdated
|
||
owners := l.GetOwnerReferences() | ||
if len(owners) == 0 { | ||
return &metric.Family{ | ||
Metrics: []*metric.Metric{ | ||
{ | ||
LabelKeys: labelKeys, | ||
LabelValues: []string{"<none>", "<none>"}, | ||
LabelValues: []string{"<none>", "<none>", l.Namespace, *l.Spec.HolderIdentity}, |
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 *l.Spec.HolderIdentity
be nil in some cases?
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.
Yes HolderIdentity is optional. Thanks for catching this!
internal/store/lease.go
Outdated
var holder string | ||
if l.Spec.HolderIdentity == nil { | ||
holder = "<none>" | ||
} else { | ||
holder = *l.Spec.HolderIdentity | ||
} | ||
|
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.
var holder string | |
if l.Spec.HolderIdentity == nil { | |
holder = "<none>" | |
} else { | |
holder = *l.Spec.HolderIdentity | |
} | |
var holder string | |
if l.Spec.HolderIdentity != nil { | |
holder = *l.Spec.HolderIdentity | |
} | |
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.
Just one small nit, otherwise looks good
internal/store/lease.go
Outdated
labelKeys := []string{"owner_kind", "owner_name"} | ||
labelKeys := []string{"owner_kind", "owner_name", "namespace", "lease_holder"} | ||
|
||
holder = "<none>" |
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.
Sorry if I was not very specific here, but I don't think we use this placeholder anywhere else, so we should not introduce it. It's fine to leave the holder
label empty when there is no holder.
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.
Got it! I was trying to match the owner_name
and owner_kind
values when they're empty, but thanks for the clarification!
Thank you for the contribution! /lgtm |
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.
/lgtm
/approve
/unhold
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dgrisonnet, fpetkovski, lantingchiang 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 |
What this PR does / why we need it: This PR modifies the Lease store's
createLeaseListWatch()
method so that the metrics for the Lease custom resource to be exported across all namespaces, as opposed to only thekube-node-lease
namespace. This allows us to get metrics on Lease resources used by pods as well.How does this change affect the cardinality of KSM: increases cardinality by the number of namespaces
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #