Skip to content

Commit 118bf10

Browse files
NodeFit inter-pod anti-affinity check returns early if affinity spec not set
1 parent 0a1303d commit 118bf10

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/descheduler/node/node.go

+4
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,10 @@ func PodMatchNodeSelector(pod *v1.Pod, node *v1.Node) bool {
335335
// of another pod that is already on the given node.
336336
// If a match is found, it returns true.
337337
func podMatchesInterPodAntiAffinity(nodeIndexer podutil.GetPodsAssignedToNodeFunc, pod *v1.Pod, node *v1.Node) (bool, error) {
338+
if pod.Spec.Affinity == nil || pod.Spec.Affinity.PodAntiAffinity == nil {
339+
return false, nil
340+
}
341+
338342
podsOnNode, err := podutil.ListPodsOnANode(node.Name, nodeIndexer, nil)
339343
if err != nil {
340344
return false, fmt.Errorf("error listing all pods: %v", err)

0 commit comments

Comments
 (0)