From 7a352b2b92e76532c6fcc2a27f60912112a7d556 Mon Sep 17 00:00:00 2001 From: "Bobby (Babak) Salamat" Date: Fri, 2 Nov 2018 15:15:45 -0700 Subject: [PATCH] Do not allocate memory for pods that do not have inter-pod affinity/anti-affinity --- pkg/scheduler/algorithm/predicates/metadata.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/scheduler/algorithm/predicates/metadata.go b/pkg/scheduler/algorithm/predicates/metadata.go index 7d63c45060..3feb23e493 100644 --- a/pkg/scheduler/algorithm/predicates/metadata.go +++ b/pkg/scheduler/algorithm/predicates/metadata.go @@ -399,7 +399,7 @@ func getTPMapMatchingExistingAntiAffinity(pod *v1.Pod, nodeInfoMap map[string]*s appendTopologyPairsMaps(existingPodTopologyMaps) } } - workqueue.Parallelize(16, len(allNodeNames), processNode) + workqueue.ParallelizeUntil(context.TODO(), 16, len(allNodeNames), processNode) return topologyMaps, firstError } @@ -408,13 +408,12 @@ func getTPMapMatchingExistingAntiAffinity(pod *v1.Pod, nodeInfoMap map[string]*s // predicate. With this topologyPairsMaps available, the affinity predicate does not // need to check all the pods in the cluster. func getTPMapMatchingIncomingAffinityAntiAffinity(pod *v1.Pod, nodeInfoMap map[string]*schedulercache.NodeInfo) (topologyPairsAffinityPodsMaps *topologyPairsMaps, topologyPairsAntiAffinityPodsMaps *topologyPairsMaps, err error) { - allNodeNames := make([]string, 0, len(nodeInfoMap)) - affinity := pod.Spec.Affinity if affinity == nil || (affinity.PodAffinity == nil && affinity.PodAntiAffinity == nil) { return newTopologyPairsMaps(), newTopologyPairsMaps(), nil } + allNodeNames := make([]string, 0, len(nodeInfoMap)) for name := range nodeInfoMap { allNodeNames = append(allNodeNames, name) }