Skip to content

Commit c554a40

Browse files
committed
it removes the field selector if it does not contain node name
1 parent 846dabf commit c554a40

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/store/node.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -523,13 +523,17 @@ func wrapNodeFunc(f func(*v1.Node) *metric.Family) func(interface{}) *metric.Fam
523523
}
524524

525525
func createNodeListWatch(kubeClient clientset.Interface, _ string, fieldSelector string) cache.ListerWatcher {
526-
// if given node name, it then lists and watches specified node by its name instead of all nodes.
526+
// if node name given, it then lists and watches specified node by its name instead of all nodes.
527527
if fieldSelector != "" {
528528
selector, _ := fields.ParseSelector(fieldSelector)
529529
nodeName, ok := selector.RequiresExactMatch("spec.nodeName")
530530
if ok {
531531
fieldSelector = fields.OneTermEqualSelector("metadata.name", nodeName).String()
532532
klog.InfoS("Transform fieldSelector for node store", "fieldSelector", fieldSelector)
533+
} else {
534+
// it removes the field selector if it does not contain node name.
535+
// for example, the namespace selector is not necessary for nodes resource.
536+
fieldSelector = ""
533537
}
534538
}
535539
return &cache.ListWatch{

0 commit comments

Comments
 (0)