Skip to content

Commit dc79b3e

Browse files
committed
Add filtering for Lease metrics
1 parent 3fb1e86 commit dc79b3e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

internal/store/lease.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,15 @@ func wrapLeaseFunc(f func(*coordinationv1.Lease) *metric.Family) func(interface{
116116
}
117117
}
118118

119-
func createLeaseListWatch(kubeClient clientset.Interface, _ string, _ string) cache.ListerWatcher {
119+
func createLeaseListWatch(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher {
120120
return &cache.ListWatch{
121121
ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) {
122-
return kubeClient.CoordinationV1().Leases("").List(context.TODO(), opts)
122+
opts.FieldSelector = fieldSelector
123+
return kubeClient.CoordinationV1().Leases(ns).List(context.TODO(), opts)
123124
},
124125
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
125-
return kubeClient.CoordinationV1().Leases("").Watch(context.TODO(), opts)
126+
opts.FieldSelector = fieldSelector
127+
return kubeClient.CoordinationV1().Leases(ns).Watch(context.TODO(), opts)
126128
},
127129
}
128130
}

0 commit comments

Comments
 (0)