Merge pull request #125303 from AxeZhan/evaluatedNodes

[Scheduler] Change back to original way of calculating EvaluatedNodes.
This commit is contained in:
Kubernetes Prow Robot
2024-06-04 06:33:13 -07:00
committed by GitHub
4 changed files with 6 additions and 22 deletions

View File

@@ -339,9 +339,6 @@ type Diagnosis struct {
PreFilterMsg string
// PostFilterMsg records the messages returned from PostFilter plugins.
PostFilterMsg string
// EvaluatedNodes records the number of nodes evaluated by Filter stage.
// It is used for debugging purposes only.
EvaluatedNodes int
}
// FitError describes a fit error of a pod.

View File

@@ -417,7 +417,7 @@ func (sched *Scheduler) schedulePod(ctx context.Context, fwk framework.Framework
if len(feasibleNodes) == 1 {
return ScheduleResult{
SuggestedHost: feasibleNodes[0].Node().Name,
EvaluatedNodes: diagnosis.EvaluatedNodes,
EvaluatedNodes: 1 + len(diagnosis.NodeToStatusMap),
FeasibleNodes: 1,
}, nil
}
@@ -432,7 +432,7 @@ func (sched *Scheduler) schedulePod(ctx context.Context, fwk framework.Framework
return ScheduleResult{
SuggestedHost: host,
EvaluatedNodes: diagnosis.EvaluatedNodes,
EvaluatedNodes: len(feasibleNodes) + len(diagnosis.NodeToStatusMap),
FeasibleNodes: len(feasibleNodes),
}, err
}
@@ -589,7 +589,6 @@ func (sched *Scheduler) findNodesThatPassFilters(
for i := range feasibleNodes {
feasibleNodes[i] = nodes[(sched.nextStartNodeIndex+i)%numAllNodes]
}
diagnosis.EvaluatedNodes = int(numNodesToFind)
return feasibleNodes, nil
}
@@ -638,13 +637,11 @@ func (sched *Scheduler) findNodesThatPassFilters(
// are found.
fwk.Parallelizer().Until(ctx, numAllNodes, checkNode, metrics.Filter)
feasibleNodes = feasibleNodes[:feasibleNodesLen]
diagnosis.EvaluatedNodes = int(feasibleNodesLen)
for _, item := range result {
if item == nil {
continue
}
diagnosis.NodeToStatusMap[item.node] = item.status
diagnosis.EvaluatedNodes++
diagnosis.AddPluginStatus(item.status)
}
if err := errCh.ReceiveError(); err != nil {

View File

@@ -937,7 +937,6 @@ func TestSchedulerNoPhantomPodAfterDelete(t *testing.T) {
node.Name: framework.NewStatus(framework.Unschedulable, nodeports.ErrReason).WithPlugin(nodeports.Name),
},
UnschedulablePlugins: sets.New(nodeports.Name),
EvaluatedNodes: 1,
},
}
if !reflect.DeepEqual(expectErr, err) {
@@ -1045,7 +1044,6 @@ func TestSchedulerFailedSchedulingReasons(t *testing.T) {
Diagnosis: framework.Diagnosis{
NodeToStatusMap: failedNodeStatues,
UnschedulablePlugins: sets.New(noderesources.Name),
EvaluatedNodes: 100,
},
}
if len(fmt.Sprint(expectErr)) > 150 {
@@ -1833,7 +1831,6 @@ func TestSchedulerSchedulePod(t *testing.T) {
"node2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("FalseFilter"),
},
UnschedulablePlugins: sets.New("FalseFilter"),
EvaluatedNodes: 2,
},
},
},
@@ -1924,7 +1921,6 @@ func TestSchedulerSchedulePod(t *testing.T) {
"1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("FalseFilter"),
},
UnschedulablePlugins: sets.New("FalseFilter"),
EvaluatedNodes: 3,
},
},
},
@@ -1951,7 +1947,6 @@ func TestSchedulerSchedulePod(t *testing.T) {
"2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("NoPodsFilter"),
},
UnschedulablePlugins: sets.New("MatchFilter", "NoPodsFilter"),
EvaluatedNodes: 2,
},
},
},
@@ -2117,7 +2112,6 @@ func TestSchedulerSchedulePod(t *testing.T) {
"3": framework.NewStatus(framework.Unschedulable, "injecting failure for pod test-filter").WithPlugin("FakeFilter"),
},
UnschedulablePlugins: sets.New("FakeFilter"),
EvaluatedNodes: 1,
},
},
},
@@ -2151,7 +2145,6 @@ func TestSchedulerSchedulePod(t *testing.T) {
"3": framework.NewStatus(framework.Unschedulable, "injecting failure for pod test-filter").WithPlugin("FakeFilter"),
},
UnschedulablePlugins: sets.New("FakeFilter", framework.ExtenderName),
EvaluatedNodes: 3,
},
},
},
@@ -2177,7 +2170,6 @@ func TestSchedulerSchedulePod(t *testing.T) {
"3": framework.NewStatus(framework.UnschedulableAndUnresolvable, "injecting failure for pod test-filter").WithPlugin("FakeFilter"),
},
UnschedulablePlugins: sets.New("FakeFilter"),
EvaluatedNodes: 1,
},
},
},
@@ -2256,9 +2248,10 @@ func TestSchedulerSchedulePod(t *testing.T) {
),
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
},
nodes: []string{"node1", "node2", "node3"},
pod: st.MakePod().Name("test-prefilter").UID("test-prefilter").Obj(),
wantNodes: sets.New("node2"),
nodes: []string{"node1", "node2", "node3"},
pod: st.MakePod().Name("test-prefilter").UID("test-prefilter").Obj(),
wantNodes: sets.New("node2"),
// since this case has no score plugin, we'll only try to find one node in Filter stage
wantEvaluatedNodes: ptr.To[int32](1),
},
{
@@ -2347,7 +2340,6 @@ func TestSchedulerSchedulePod(t *testing.T) {
"node2": framework.NewStatus(framework.Unschedulable, "injecting failure for pod test-prefilter").WithPlugin("FakeFilter"),
},
UnschedulablePlugins: sets.New("FakeFilter"),
EvaluatedNodes: 1,
PreFilterMsg: "",
},
},
@@ -2571,7 +2563,6 @@ func TestFindFitAllError(t *testing.T) {
"3": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("MatchFilter"),
},
UnschedulablePlugins: sets.New("MatchFilter"),
EvaluatedNodes: 3,
}
if diff := cmp.Diff(diagnosis, expected); diff != "" {
t.Errorf("Unexpected diagnosis: (-want, +got): %s", diff)

View File

@@ -139,7 +139,6 @@ type ScheduleResult struct {
SuggestedHost string
// The number of nodes the scheduler evaluated the pod against in the filtering
// phase and beyond.
// Note that it contains the number of nodes that filtered out by PreFilterResult.
EvaluatedNodes int
// The number of nodes out of the evaluated ones that fit the pod.
FeasibleNodes int