Hold mutex lock shorter when processing inter-pod affinity/anti-affinity priority function

This commit is contained in:
Bobby (Babak) Salamat 2018-11-02 20:56:17 -07:00
parent a5612a1504
commit aa8b5b431b

View File

@ -92,15 +92,13 @@ func (p *podAffinityPriorityMap) processTerm(term *v1.PodAffinityTerm, podDefini
} }
match := priorityutil.PodMatchesTermsNamespaceAndSelector(podToCheck, namespaces, selector) match := priorityutil.PodMatchesTermsNamespaceAndSelector(podToCheck, namespaces, selector)
if match { if match {
func() { for _, node := range p.nodes {
p.Lock() if priorityutil.NodesHaveSameTopologyKey(node, fixedNode, term.TopologyKey) {
defer p.Unlock() p.Lock()
for _, node := range p.nodes { p.counts[node.Name] += weight
if priorityutil.NodesHaveSameTopologyKey(node, fixedNode, term.TopologyKey) { p.Unlock()
p.counts[node.Name] += weight
}
} }
}() }
} }
} }