Skip to content

Commit

Permalink
Merge pull request #2122 from ntoofu/fix-2121
Browse files Browse the repository at this point in the history
fix: Add filtering for Lease metrics
  • Loading branch information
k8s-ci-robot committed Jul 26, 2023
2 parents 89c1bc3 + dc79b3e commit 71e099b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/store/lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
}
}

0 comments on commit 71e099b

Please sign in to comment.