@@ -295,10 +295,10 @@ func (s *Scheduler) schedulePod(ctx context.Context, pod *corev1.Pod) (err error
295295func (s * Scheduler ) checkForAndEnqueuePendingPods (ctx context.Context , schedulerQueue chan <- * corev1.Pod ) error {
296296 tracing .FromContext (ctx , "checkForAndEnqueuePendingPods" )
297297
298- // We want to scan for pods we have to schedule. As we have a) no local queue and b) can only filter by labels,
299- // we query all here and filter later, manually. Sadly, this polls the Kubernetes api quite often.
298+ // We want to scan the namespace for pods we have to schedule. As we have a) no local queue and b) can only filter
299+ // by labels, we query all here and filter later, manually. Sadly, this polls the Kubernetes api quite often.
300300 // TODO Consider using a local queue of pending pods and try to do the full ".List" only very rarely
301- allPods , podsErr := s .pods .Lister ().List (labels .Everything ())
301+ allPods , podsErr := s .pods .Lister ().Pods ( s . Config . Namespace ). List (labels .Everything ())
302302 if podsErr != nil {
303303 return xerrors .Errorf ("cannot list all pods: %w" , podsErr )
304304 }
@@ -342,8 +342,10 @@ func (s *Scheduler) buildState(ctx context.Context, pod *corev1.Pod) (state *Sta
342342 return nil , err
343343 }
344344
345- // We need to take _all_ pods into account to accurately calculate available RAM per node
346- allPods , podsErr := s .pods .Lister ().List (labels .Everything ())
345+ // We need to take into account _all_ pods in _all_ namespaces to accurately calculate available RAM per node
346+ // NOTE: .Pods("") - in contrast to omitting it and calling .Lister().List(...) directly - means:
347+ // List from _all_ namespaces !!!
348+ allPods , podsErr := s .pods .Lister ().Pods (metav1 .NamespaceAll ).List (labels .Everything ())
347349 if podsErr != nil {
348350 return nil , xerrors .Errorf ("cannot list all pods: %w" , podsErr )
349351 }
0 commit comments