mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-14 06:15:45 +00:00
Fast return when no any matched anti-affinity terms
When check the incoming pod's anti-affinity rules, there is change to return early when there is no any matched anti-affinity terms in the whole cluster.
This commit is contained in:
parent
9b78bd5979
commit
75ccb90407
@ -330,11 +330,13 @@ func satisfyExistingPodsAntiAffinity(state *preFilterState, nodeInfo *framework.
|
|||||||
|
|
||||||
// Checks if the node satisifies the incoming pod's anti-affinity rules.
|
// Checks if the node satisifies the incoming pod's anti-affinity rules.
|
||||||
func satisfyPodAntiAffinity(state *preFilterState, nodeInfo *framework.NodeInfo) bool {
|
func satisfyPodAntiAffinity(state *preFilterState, nodeInfo *framework.NodeInfo) bool {
|
||||||
for _, term := range state.podInfo.RequiredAntiAffinityTerms {
|
if len(state.topologyToMatchedAntiAffinityTerms) > 0 {
|
||||||
if topologyValue, ok := nodeInfo.Node().Labels[term.TopologyKey]; ok {
|
for _, term := range state.podInfo.RequiredAntiAffinityTerms {
|
||||||
tp := topologyPair{key: term.TopologyKey, value: topologyValue}
|
if topologyValue, ok := nodeInfo.Node().Labels[term.TopologyKey]; ok {
|
||||||
if state.topologyToMatchedAntiAffinityTerms[tp] > 0 {
|
tp := topologyPair{key: term.TopologyKey, value: topologyValue}
|
||||||
return false
|
if state.topologyToMatchedAntiAffinityTerms[tp] > 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user