Merge pull request #93843 from soulxu/fast_path_podaffinity

Fast return when no any matched anti-affinity terms
This commit is contained in:
Kubernetes Prow Robot 2020-09-04 03:31:55 -07:00 committed by GitHub
commit 217d89a59f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -330,6 +330,7 @@ func satisfyExistingPodsAntiAffinity(state *preFilterState, nodeInfo *framework.
// Checks if the node satisifies the incoming pod's anti-affinity rules.
func satisfyPodAntiAffinity(state *preFilterState, nodeInfo *framework.NodeInfo) bool {
if len(state.topologyToMatchedAntiAffinityTerms) > 0 {
for _, term := range state.podInfo.RequiredAntiAffinityTerms {
if topologyValue, ok := nodeInfo.Node().Labels[term.TopologyKey]; ok {
tp := topologyPair{key: term.TopologyKey, value: topologyValue}
@ -338,6 +339,7 @@ func satisfyPodAntiAffinity(state *preFilterState, nodeInfo *framework.NodeInfo)
}
}
}
}
return true
}