mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #94125 from soulxu/only_includes_all_nodes_for_preferred
Only process all nodes when incoming pod has no preferred affinity
This commit is contained in:
commit
b837699f74
@ -141,14 +141,14 @@ func (pl *InterPodAffinity) PreScore(
|
|||||||
}
|
}
|
||||||
|
|
||||||
affinity := pod.Spec.Affinity
|
affinity := pod.Spec.Affinity
|
||||||
hasAffinityConstraints := affinity != nil && affinity.PodAffinity != nil
|
hasPreferredAffinityConstraints := affinity != nil && affinity.PodAffinity != nil && len(affinity.PodAffinity.PreferredDuringSchedulingIgnoredDuringExecution) > 0
|
||||||
hasAntiAffinityConstraints := affinity != nil && affinity.PodAntiAffinity != nil
|
hasPreferredAntiAffinityConstraints := affinity != nil && affinity.PodAntiAffinity != nil && len(affinity.PodAntiAffinity.PreferredDuringSchedulingIgnoredDuringExecution) > 0
|
||||||
|
|
||||||
// Unless the pod being scheduled has affinity terms, we only
|
// Unless the pod being scheduled has preferred affinity terms, we only
|
||||||
// need to process nodes hosting pods with affinity.
|
// need to process nodes hosting pods with affinity.
|
||||||
var allNodes []*framework.NodeInfo
|
var allNodes []*framework.NodeInfo
|
||||||
var err error
|
var err error
|
||||||
if hasAffinityConstraints || hasAntiAffinityConstraints {
|
if hasPreferredAffinityConstraints || hasPreferredAntiAffinityConstraints {
|
||||||
allNodes, err = pl.sharedLister.NodeInfos().List()
|
allNodes, err = pl.sharedLister.NodeInfos().List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.NewStatus(framework.Error, fmt.Sprintf("get all nodes from shared lister error, err: %v", err))
|
framework.NewStatus(framework.Error, fmt.Sprintf("get all nodes from shared lister error, err: %v", err))
|
||||||
@ -178,10 +178,10 @@ func (pl *InterPodAffinity) PreScore(
|
|||||||
if nodeInfo.Node() == nil {
|
if nodeInfo.Node() == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Unless the pod being scheduled has affinity terms, we only
|
// Unless the pod being scheduled has preferred affinity terms, we only
|
||||||
// need to process pods with affinity in the node.
|
// need to process pods with affinity in the node.
|
||||||
podsToProcess := nodeInfo.PodsWithAffinity
|
podsToProcess := nodeInfo.PodsWithAffinity
|
||||||
if hasAffinityConstraints || hasAntiAffinityConstraints {
|
if hasPreferredAffinityConstraints || hasPreferredAntiAffinityConstraints {
|
||||||
// We need to process all the pods.
|
// We need to process all the pods.
|
||||||
podsToProcess = nodeInfo.Pods
|
podsToProcess = nodeInfo.Pods
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user