Skip to content

Commit

Permalink
Fix: Remove FieldSelector from non-namespaced resources
Browse files Browse the repository at this point in the history
This should resolve the issue with namespace-denylist as discovered in kubernetes#2187

Regression introduced in kubernetes@c3c5528

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
  • Loading branch information
mrueg committed Sep 11, 2023
1 parent 39d76ab commit 880133b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
4 changes: 1 addition & 3 deletions internal/store/certificatesigningrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,12 @@ func wrapCSRFunc(f func(*certv1.CertificateSigningRequest) *metric.Family) func(
}
}

func createCSRListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher {
func createCSRListWatch(kubeClient clientset.Interface, _ string, _ string) cache.ListerWatcher {
return &cache.ListWatch{
ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) {
opts.FieldSelector = fieldSelector
return kubeClient.CertificatesV1().CertificateSigningRequests().List(context.TODO(), opts)
},
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
opts.FieldSelector = fieldSelector
return kubeClient.CertificatesV1().CertificateSigningRequests().Watch(context.TODO(), opts)
},
}
Expand Down
4 changes: 1 addition & 3 deletions internal/store/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,12 @@ func wrapNamespaceFunc(f func(*v1.Namespace) *metric.Family) func(interface{}) *
}
}

func createNamespaceListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher {
func createNamespaceListWatch(kubeClient clientset.Interface, _ string, _ string) cache.ListerWatcher {
return &cache.ListWatch{
ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) {
opts.FieldSelector = fieldSelector
return kubeClient.CoreV1().Namespaces().List(context.TODO(), opts)
},
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
opts.FieldSelector = fieldSelector
return kubeClient.CoreV1().Namespaces().Watch(context.TODO(), opts)
},
}
Expand Down
4 changes: 1 addition & 3 deletions internal/store/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,12 @@ func wrapNodeFunc(f func(*v1.Node) *metric.Family) func(interface{}) *metric.Fam
}
}

func createNodeListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher {
func createNodeListWatch(kubeClient clientset.Interface, _ string, _ string) cache.ListerWatcher {
return &cache.ListWatch{
ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) {
opts.FieldSelector = fieldSelector
return kubeClient.CoreV1().Nodes().List(context.TODO(), opts)
},
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
opts.FieldSelector = fieldSelector
return kubeClient.CoreV1().Nodes().Watch(context.TODO(), opts)
},
}
Expand Down

0 comments on commit 880133b

Please sign in to comment.