Skip to content

Commit 023f83d

Browse files
mruegdgrisonnet
authored andcommitted
Fix: Remove FieldSelector from non-namespaced resources
This should resolve the issue with namespace-denylist as discovered in #2187 Regression introduced in c3c5528 Signed-off-by: Manuel Rüger <[email protected]>
1 parent e8272ce commit 023f83d

File tree

7 files changed

+7
-21
lines changed

7 files changed

+7
-21
lines changed

internal/store/certificatesigningrequest.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,12 @@ func wrapCSRFunc(f func(*certv1.CertificateSigningRequest) *metric.Family) func(
153153
}
154154
}
155155

156-
func createCSRListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher {
156+
func createCSRListWatch(kubeClient clientset.Interface, _ string, _ string) cache.ListerWatcher {
157157
return &cache.ListWatch{
158158
ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) {
159-
opts.FieldSelector = fieldSelector
160159
return kubeClient.CertificatesV1().CertificateSigningRequests().List(context.TODO(), opts)
161160
},
162161
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
163-
opts.FieldSelector = fieldSelector
164162
return kubeClient.CertificatesV1().CertificateSigningRequests().Watch(context.TODO(), opts)
165163
},
166164
}

internal/store/clusterrole.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,12 @@ func clusterRoleMetricFamilies(allowAnnotationsList, allowLabelsList []string) [
138138
}
139139
}
140140

141-
func createClusterRoleListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher {
141+
func createClusterRoleListWatch(kubeClient clientset.Interface, _ string, _ string) cache.ListerWatcher {
142142
return &cache.ListWatch{
143143
ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) {
144-
opts.FieldSelector = fieldSelector
145144
return kubeClient.RbacV1().ClusterRoles().List(context.TODO(), opts)
146145
},
147146
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
148-
opts.FieldSelector = fieldSelector
149147
return kubeClient.RbacV1().ClusterRoles().Watch(context.TODO(), opts)
150148
},
151149
}

internal/store/mutatingwebhookconfiguration.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,12 @@ var (
111111
}
112112
)
113113

114-
func createMutatingWebhookConfigurationListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher {
114+
func createMutatingWebhookConfigurationListWatch(kubeClient clientset.Interface, _ string, _ string) cache.ListerWatcher {
115115
return &cache.ListWatch{
116116
ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) {
117-
opts.FieldSelector = fieldSelector
118117
return kubeClient.AdmissionregistrationV1().MutatingWebhookConfigurations().List(context.TODO(), opts)
119118
},
120119
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
121-
opts.FieldSelector = fieldSelector
122120
return kubeClient.AdmissionregistrationV1().MutatingWebhookConfigurations().Watch(context.TODO(), opts)
123121
},
124122
}

internal/store/namespace.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,12 @@ func wrapNamespaceFunc(f func(*v1.Namespace) *metric.Family) func(interface{}) *
176176
}
177177
}
178178

179-
func createNamespaceListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher {
179+
func createNamespaceListWatch(kubeClient clientset.Interface, _ string, _ string) cache.ListerWatcher {
180180
return &cache.ListWatch{
181181
ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) {
182-
opts.FieldSelector = fieldSelector
183182
return kubeClient.CoreV1().Namespaces().List(context.TODO(), opts)
184183
},
185184
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
186-
opts.FieldSelector = fieldSelector
187185
return kubeClient.CoreV1().Namespaces().Watch(context.TODO(), opts)
188186
},
189187
}

internal/store/node.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,14 +495,12 @@ func wrapNodeFunc(f func(*v1.Node) *metric.Family) func(interface{}) *metric.Fam
495495
}
496496
}
497497

498-
func createNodeListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher {
498+
func createNodeListWatch(kubeClient clientset.Interface, _ string, _ string) cache.ListerWatcher {
499499
return &cache.ListWatch{
500500
ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) {
501-
opts.FieldSelector = fieldSelector
502501
return kubeClient.CoreV1().Nodes().List(context.TODO(), opts)
503502
},
504503
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
505-
opts.FieldSelector = fieldSelector
506504
return kubeClient.CoreV1().Nodes().Watch(context.TODO(), opts)
507505
},
508506
}

internal/store/persistentvolume.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,12 @@ func wrapPersistentVolumeFunc(f func(*v1.PersistentVolume) *metric.Family) func(
366366
}
367367
}
368368

369-
func createPersistentVolumeListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher {
369+
func createPersistentVolumeListWatch(kubeClient clientset.Interface, _ string, _ string) cache.ListerWatcher {
370370
return &cache.ListWatch{
371371
ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) {
372-
opts.FieldSelector = fieldSelector
373372
return kubeClient.CoreV1().PersistentVolumes().List(context.TODO(), opts)
374373
},
375374
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
376-
opts.FieldSelector = fieldSelector
377375
return kubeClient.CoreV1().PersistentVolumes().Watch(context.TODO(), opts)
378376
},
379377
}

internal/store/validatingwebhookconfiguration.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,12 @@ var (
111111
}
112112
)
113113

114-
func createValidatingWebhookConfigurationListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher {
114+
func createValidatingWebhookConfigurationListWatch(kubeClient clientset.Interface, _ string, _ string) cache.ListerWatcher {
115115
return &cache.ListWatch{
116116
ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) {
117-
opts.FieldSelector = fieldSelector
118117
return kubeClient.AdmissionregistrationV1().ValidatingWebhookConfigurations().List(context.TODO(), opts)
119118
},
120119
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
121-
opts.FieldSelector = fieldSelector
122120
return kubeClient.AdmissionregistrationV1().ValidatingWebhookConfigurations().Watch(context.TODO(), opts)
123121
},
124122
}

0 commit comments

Comments
 (0)