Merge pull request #2122 from ntoofu/fix-2121

fix: Add filtering for Lease metrics
This commit is contained in:
Kubernetes Prow Robot 2023-07-26 03:40:17 -07:00 committed by GitHub
commit 71e099bfb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -116,13 +116,15 @@ func wrapLeaseFunc(f func(*coordinationv1.Lease) *metric.Family) func(interface{
}
}
func createLeaseListWatch(kubeClient clientset.Interface, _ string, _ string) cache.ListerWatcher {
func createLeaseListWatch(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher {
return &cache.ListWatch{
ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) {
return kubeClient.CoordinationV1().Leases("").List(context.TODO(), opts)
opts.FieldSelector = fieldSelector
return kubeClient.CoordinationV1().Leases(ns).List(context.TODO(), opts)
},
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
return kubeClient.CoordinationV1().Leases("").Watch(context.TODO(), opts)
opts.FieldSelector = fieldSelector
return kubeClient.CoordinationV1().Leases(ns).Watch(context.TODO(), opts)
},
}
}