Merge pull request #70605 from bsalamat/affinity_lock_opt

Hold mutex lock shorter when processing inter-pod affinity/anti-affin…
This commit is contained in:
k8s-ci-robot 2018-11-04 11:59:05 -08:00 committed by GitHub
commit 774b18491f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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
}
} }
}() }
} }
} }