Unverified Commit 582b88c8 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #64995 from bsalamat/preempt_opt

Automatic merge from submit-queue (batch tested with PRs 65388, 64995). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add more conditions to the list of predicate failures that won't be resolved by preemption **What this PR does / why we need it**: Adds more conditions to the list of predicate failures that won't be resolved by preemption. This change can potentially improve performance of preemption by avoiding the nodes that won't be able to schedule the pending pod no matter how many other pods are removed from them. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note Add more conditions to the list of predicate failures that won't be resolved by preemption. ``` /sig scheduling
parents 966c77c8 8cdf83ed
...@@ -986,11 +986,19 @@ func nodesWherePreemptionMightHelp(nodes []*v1.Node, failedPredicatesMap FailedP ...@@ -986,11 +986,19 @@ func nodesWherePreemptionMightHelp(nodes []*v1.Node, failedPredicatesMap FailedP
switch failedPredicate { switch failedPredicate {
case case
predicates.ErrNodeSelectorNotMatch, predicates.ErrNodeSelectorNotMatch,
predicates.ErrPodAffinityRulesNotMatch,
predicates.ErrPodNotMatchHostName, predicates.ErrPodNotMatchHostName,
predicates.ErrTaintsTolerationsNotMatch, predicates.ErrTaintsTolerationsNotMatch,
predicates.ErrNodeLabelPresenceViolated, predicates.ErrNodeLabelPresenceViolated,
// Node conditions won't change when scheduler simulates removal of preemption victims.
// So, it is pointless to try nodes that have not been able to host the pod due to node
// conditions. These include ErrNodeNotReady, ErrNodeUnderPIDPressure, ErrNodeUnderMemoryPressure, ....
predicates.ErrNodeNotReady, predicates.ErrNodeNotReady,
predicates.ErrNodeNetworkUnavailable, predicates.ErrNodeNetworkUnavailable,
predicates.ErrNodeUnderDiskPressure,
predicates.ErrNodeUnderPIDPressure,
predicates.ErrNodeUnderMemoryPressure,
predicates.ErrNodeOutOfDisk,
predicates.ErrNodeUnschedulable, predicates.ErrNodeUnschedulable,
predicates.ErrNodeUnknownCondition, predicates.ErrNodeUnknownCondition,
predicates.ErrVolumeZoneConflict, predicates.ErrVolumeZoneConflict,
...@@ -998,7 +1006,6 @@ func nodesWherePreemptionMightHelp(nodes []*v1.Node, failedPredicatesMap FailedP ...@@ -998,7 +1006,6 @@ func nodesWherePreemptionMightHelp(nodes []*v1.Node, failedPredicatesMap FailedP
predicates.ErrVolumeBindConflict: predicates.ErrVolumeBindConflict:
unresolvableReasonExist = true unresolvableReasonExist = true
break break
// TODO(bsalamat): Please add affinity failure cases once we have specific affinity failure errors.
} }
} }
if !found || !unresolvableReasonExist { if !found || !unresolvableReasonExist {
......
...@@ -1112,7 +1112,7 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) { ...@@ -1112,7 +1112,7 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) {
expected: map[string]bool{}, expected: map[string]bool{},
}, },
{ {
name: "pod affinity should be tried", name: "ErrPodAffinityNotMatch should be tried as it indicates that the pod is unschedulable due to inter-pod affinity or anti-affinity",
failedPredMap: FailedPredicateMap{ failedPredMap: FailedPredicateMap{
"machine1": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodAffinityNotMatch}, "machine1": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodAffinityNotMatch},
"machine2": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodNotMatchHostName}, "machine2": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodNotMatchHostName},
...@@ -1129,6 +1129,14 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) { ...@@ -1129,6 +1129,14 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) {
expected: map[string]bool{"machine1": true, "machine3": true, "machine4": true}, expected: map[string]bool{"machine1": true, "machine3": true, "machine4": true},
}, },
{ {
name: "ErrPodAffinityRulesNotMatch should not be tried as it indicates that the pod is unschedulable due to inter-pod affinity, but ErrPodAffinityNotMatch should be tried as it indicates that the pod is unschedulable due to inter-pod affinity or anti-affinity",
failedPredMap: FailedPredicateMap{
"machine1": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodAffinityRulesNotMatch},
"machine2": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodAffinityNotMatch},
},
expected: map[string]bool{"machine2": true, "machine3": true, "machine4": true},
},
{
name: "Mix of failed predicates works fine", name: "Mix of failed predicates works fine",
failedPredMap: FailedPredicateMap{ failedPredMap: FailedPredicateMap{
"machine1": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeSelectorNotMatch, algorithmpredicates.ErrNodeOutOfDisk, algorithmpredicates.NewInsufficientResourceError(v1.ResourceMemory, 1000, 500, 300)}, "machine1": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeSelectorNotMatch, algorithmpredicates.ErrNodeOutOfDisk, algorithmpredicates.NewInsufficientResourceError(v1.ResourceMemory, 1000, 500, 300)},
...@@ -1138,6 +1146,16 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) { ...@@ -1138,6 +1146,16 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) {
}, },
expected: map[string]bool{"machine3": true, "machine4": true}, expected: map[string]bool{"machine3": true, "machine4": true},
}, },
{
name: "Node condition errors should be considered unresolvable",
failedPredMap: FailedPredicateMap{
"machine1": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeUnderDiskPressure},
"machine2": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeUnderPIDPressure},
"machine3": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeUnderMemoryPressure},
"machine4": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeOutOfDisk},
},
expected: map[string]bool{},
},
} }
for _, test := range tests { for _, test := range tests {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment