From dc79b3e9279809756f41e3470412f5cb917651e4 Mon Sep 17 00:00:00 2001 From: ntoofu Date: Fri, 21 Jul 2023 04:07:32 +0900 Subject: [PATCH] Add filtering for Lease metrics --- internal/store/lease.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/store/lease.go b/internal/store/lease.go index f755f1dfb6..3df4251da0 100644 --- a/internal/store/lease.go +++ b/internal/store/lease.go @@ -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) }, } }