Skip to content

Commit ae5543e

Browse files
authored
Merge pull request kubernetes#125303 from AxeZhan/evaluatedNodes
[Scheduler] Change back to original way of calculating EvaluatedNodes.
2 parents e6d6416 + cf73c9d commit ae5543e

File tree

4 files changed

+6
-22
lines changed

4 files changed

+6
-22
lines changed

pkg/scheduler/framework/types.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,6 @@ type Diagnosis struct {
339339
PreFilterMsg string
340340
// PostFilterMsg records the messages returned from PostFilter plugins.
341341
PostFilterMsg string
342-
// EvaluatedNodes records the number of nodes evaluated by Filter stage.
343-
// It is used for debugging purposes only.
344-
EvaluatedNodes int
345342
}
346343

347344
// FitError describes a fit error of a pod.

pkg/scheduler/schedule_one.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func (sched *Scheduler) schedulePod(ctx context.Context, fwk framework.Framework
417417
if len(feasibleNodes) == 1 {
418418
return ScheduleResult{
419419
SuggestedHost: feasibleNodes[0].Node().Name,
420-
EvaluatedNodes: diagnosis.EvaluatedNodes,
420+
EvaluatedNodes: 1 + len(diagnosis.NodeToStatusMap),
421421
FeasibleNodes: 1,
422422
}, nil
423423
}
@@ -432,7 +432,7 @@ func (sched *Scheduler) schedulePod(ctx context.Context, fwk framework.Framework
432432

433433
return ScheduleResult{
434434
SuggestedHost: host,
435-
EvaluatedNodes: diagnosis.EvaluatedNodes,
435+
EvaluatedNodes: len(feasibleNodes) + len(diagnosis.NodeToStatusMap),
436436
FeasibleNodes: len(feasibleNodes),
437437
}, err
438438
}
@@ -589,7 +589,6 @@ func (sched *Scheduler) findNodesThatPassFilters(
589589
for i := range feasibleNodes {
590590
feasibleNodes[i] = nodes[(sched.nextStartNodeIndex+i)%numAllNodes]
591591
}
592-
diagnosis.EvaluatedNodes = int(numNodesToFind)
593592
return feasibleNodes, nil
594593
}
595594

@@ -638,13 +637,11 @@ func (sched *Scheduler) findNodesThatPassFilters(
638637
// are found.
639638
fwk.Parallelizer().Until(ctx, numAllNodes, checkNode, metrics.Filter)
640639
feasibleNodes = feasibleNodes[:feasibleNodesLen]
641-
diagnosis.EvaluatedNodes = int(feasibleNodesLen)
642640
for _, item := range result {
643641
if item == nil {
644642
continue
645643
}
646644
diagnosis.NodeToStatusMap[item.node] = item.status
647-
diagnosis.EvaluatedNodes++
648645
diagnosis.AddPluginStatus(item.status)
649646
}
650647
if err := errCh.ReceiveError(); err != nil {

pkg/scheduler/schedule_one_test.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,6 @@ func TestSchedulerNoPhantomPodAfterDelete(t *testing.T) {
937937
node.Name: framework.NewStatus(framework.Unschedulable, nodeports.ErrReason).WithPlugin(nodeports.Name),
938938
},
939939
UnschedulablePlugins: sets.New(nodeports.Name),
940-
EvaluatedNodes: 1,
941940
},
942941
}
943942
if !reflect.DeepEqual(expectErr, err) {
@@ -1045,7 +1044,6 @@ func TestSchedulerFailedSchedulingReasons(t *testing.T) {
10451044
Diagnosis: framework.Diagnosis{
10461045
NodeToStatusMap: failedNodeStatues,
10471046
UnschedulablePlugins: sets.New(noderesources.Name),
1048-
EvaluatedNodes: 100,
10491047
},
10501048
}
10511049
if len(fmt.Sprint(expectErr)) > 150 {
@@ -1833,7 +1831,6 @@ func TestSchedulerSchedulePod(t *testing.T) {
18331831
"node2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("FalseFilter"),
18341832
},
18351833
UnschedulablePlugins: sets.New("FalseFilter"),
1836-
EvaluatedNodes: 2,
18371834
},
18381835
},
18391836
},
@@ -1924,7 +1921,6 @@ func TestSchedulerSchedulePod(t *testing.T) {
19241921
"1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("FalseFilter"),
19251922
},
19261923
UnschedulablePlugins: sets.New("FalseFilter"),
1927-
EvaluatedNodes: 3,
19281924
},
19291925
},
19301926
},
@@ -1951,7 +1947,6 @@ func TestSchedulerSchedulePod(t *testing.T) {
19511947
"2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("NoPodsFilter"),
19521948
},
19531949
UnschedulablePlugins: sets.New("MatchFilter", "NoPodsFilter"),
1954-
EvaluatedNodes: 2,
19551950
},
19561951
},
19571952
},
@@ -2117,7 +2112,6 @@ func TestSchedulerSchedulePod(t *testing.T) {
21172112
"3": framework.NewStatus(framework.Unschedulable, "injecting failure for pod test-filter").WithPlugin("FakeFilter"),
21182113
},
21192114
UnschedulablePlugins: sets.New("FakeFilter"),
2120-
EvaluatedNodes: 1,
21212115
},
21222116
},
21232117
},
@@ -2151,7 +2145,6 @@ func TestSchedulerSchedulePod(t *testing.T) {
21512145
"3": framework.NewStatus(framework.Unschedulable, "injecting failure for pod test-filter").WithPlugin("FakeFilter"),
21522146
},
21532147
UnschedulablePlugins: sets.New("FakeFilter", framework.ExtenderName),
2154-
EvaluatedNodes: 3,
21552148
},
21562149
},
21572150
},
@@ -2177,7 +2170,6 @@ func TestSchedulerSchedulePod(t *testing.T) {
21772170
"3": framework.NewStatus(framework.UnschedulableAndUnresolvable, "injecting failure for pod test-filter").WithPlugin("FakeFilter"),
21782171
},
21792172
UnschedulablePlugins: sets.New("FakeFilter"),
2180-
EvaluatedNodes: 1,
21812173
},
21822174
},
21832175
},
@@ -2256,9 +2248,10 @@ func TestSchedulerSchedulePod(t *testing.T) {
22562248
),
22572249
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
22582250
},
2259-
nodes: []string{"node1", "node2", "node3"},
2260-
pod: st.MakePod().Name("test-prefilter").UID("test-prefilter").Obj(),
2261-
wantNodes: sets.New("node2"),
2251+
nodes: []string{"node1", "node2", "node3"},
2252+
pod: st.MakePod().Name("test-prefilter").UID("test-prefilter").Obj(),
2253+
wantNodes: sets.New("node2"),
2254+
// since this case has no score plugin, we'll only try to find one node in Filter stage
22622255
wantEvaluatedNodes: ptr.To[int32](1),
22632256
},
22642257
{
@@ -2347,7 +2340,6 @@ func TestSchedulerSchedulePod(t *testing.T) {
23472340
"node2": framework.NewStatus(framework.Unschedulable, "injecting failure for pod test-prefilter").WithPlugin("FakeFilter"),
23482341
},
23492342
UnschedulablePlugins: sets.New("FakeFilter"),
2350-
EvaluatedNodes: 1,
23512343
PreFilterMsg: "",
23522344
},
23532345
},
@@ -2571,7 +2563,6 @@ func TestFindFitAllError(t *testing.T) {
25712563
"3": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("MatchFilter"),
25722564
},
25732565
UnschedulablePlugins: sets.New("MatchFilter"),
2574-
EvaluatedNodes: 3,
25752566
}
25762567
if diff := cmp.Diff(diagnosis, expected); diff != "" {
25772568
t.Errorf("Unexpected diagnosis: (-want, +got): %s", diff)

pkg/scheduler/scheduler.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ type ScheduleResult struct {
139139
SuggestedHost string
140140
// The number of nodes the scheduler evaluated the pod against in the filtering
141141
// phase and beyond.
142-
// Note that it contains the number of nodes that filtered out by PreFilterResult.
143142
EvaluatedNodes int
144143
// The number of nodes out of the evaluated ones that fit the pod.
145144
FeasibleNodes int

0 commit comments

Comments
 (0)