From 7be9ef6d7499390546d55b6f1e9a24fea6d3e65f Mon Sep 17 00:00:00 2001 From: Alex Hays Date: Sat, 7 May 2022 16:38:16 -0400 Subject: [PATCH] use the PreFilterResult in SchedulerBasedPredicateChecker --- cluster-autoscaler/simulator/predicate_error.go | 2 +- .../simulator/scheduler_based_predicates_checker.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cluster-autoscaler/simulator/predicate_error.go b/cluster-autoscaler/simulator/predicate_error.go index 68f5b87c6a2d..c4a19b52bd49 100644 --- a/cluster-autoscaler/simulator/predicate_error.go +++ b/cluster-autoscaler/simulator/predicate_error.go @@ -25,7 +25,7 @@ import ( type PredicateErrorType int const ( - // NotSchedulablePredicateError means that one of the filters retuned that pod does not fit a node + // NotSchedulablePredicateError means that one of the filters returned that pod does not fit a node NotSchedulablePredicateError PredicateErrorType = iota // InternalPredicateError denotes internal unexpected error while calling PredicateChecker InternalPredicateError diff --git a/cluster-autoscaler/simulator/scheduler_based_predicates_checker.go b/cluster-autoscaler/simulator/scheduler_based_predicates_checker.go index da8d64b96c37..85be2e3ee95e 100644 --- a/cluster-autoscaler/simulator/scheduler_based_predicates_checker.go +++ b/cluster-autoscaler/simulator/scheduler_based_predicates_checker.go @@ -103,7 +103,7 @@ func (p *SchedulerBasedPredicateChecker) FitsAnyNodeMatching(clusterSnapshot Clu defer p.delegatingSharedLister.ResetDelegate() state := schedulerframework.NewCycleState() - _, preFilterStatus := p.framework.RunPreFilterPlugins(context.TODO(), state, pod) + preFilterResult, preFilterStatus := p.framework.RunPreFilterPlugins(context.TODO(), state, pod) if !preFilterStatus.IsSuccess() { return "", fmt.Errorf("error running pre filter plugins for pod %s; %s", pod.Name, preFilterStatus.Message()) } @@ -114,6 +114,10 @@ func (p *SchedulerBasedPredicateChecker) FitsAnyNodeMatching(clusterSnapshot Clu continue } + if !preFilterResult.AllNodes() && !preFilterResult.NodeNames.Has(nodeInfo.Node().Name) { + continue + } + // Be sure that the node is schedulable. if nodeInfo.Node().Spec.Unschedulable { continue