Skip to content

Commit ac6c77c

Browse files
authored
Merge pull request kubernetes#84121 from zouyee/renamefit
rename FilterPlugin NodeResources
2 parents ba4adef + 04340ea commit ac6c77c

File tree

6 files changed

+38
-38
lines changed

6 files changed

+38
-38
lines changed

pkg/scheduler/api/compatibility/compatibility_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
6262
wantPlugins: map[string][]kubeschedulerconfig.Plugin{
6363
"FilterPlugin": {
6464
{Name: "NodeUnschedulable"},
65-
{Name: "NodeResources"},
65+
{Name: "NodeResourcesFit"},
6666
{Name: "NodeName"},
6767
{Name: "NodePorts"},
6868
{Name: "NodeAffinity"},
@@ -104,7 +104,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
104104
"FilterPlugin": {
105105
{Name: "NodeUnschedulable"},
106106
{Name: "NodeAffinity"},
107-
{Name: "NodeResources"},
107+
{Name: "NodeResourcesFit"},
108108
{Name: "VolumeRestrictions"},
109109
{Name: "TaintToleration"},
110110
},
@@ -153,7 +153,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
153153
{Name: "NodeName"},
154154
{Name: "NodePorts"},
155155
{Name: "NodeAffinity"},
156-
{Name: "NodeResources"},
156+
{Name: "NodeResourcesFit"},
157157
{Name: "VolumeRestrictions"},
158158
{Name: "TaintToleration"},
159159
},
@@ -212,7 +212,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
212212
{Name: "NodeName"},
213213
{Name: "NodePorts"},
214214
{Name: "NodeAffinity"},
215-
{Name: "NodeResources"},
215+
{Name: "NodeResourcesFit"},
216216
{Name: "VolumeRestrictions"},
217217
{Name: "TaintToleration"},
218218
{Name: "VolumeZone"},
@@ -277,7 +277,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
277277
{Name: "NodeName"},
278278
{Name: "NodePorts"},
279279
{Name: "NodeAffinity"},
280-
{Name: "NodeResources"},
280+
{Name: "NodeResourcesFit"},
281281
{Name: "VolumeRestrictions"},
282282
{Name: "TaintToleration"},
283283
{Name: "VolumeZone"},
@@ -348,7 +348,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
348348
{Name: "NodeName"},
349349
{Name: "NodePorts"},
350350
{Name: "NodeAffinity"},
351-
{Name: "NodeResources"},
351+
{Name: "NodeResourcesFit"},
352352
{Name: "VolumeRestrictions"},
353353
{Name: "TaintToleration"},
354354
{Name: "VolumeZone"},
@@ -430,7 +430,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
430430
{Name: "NodeName"},
431431
{Name: "NodePorts"},
432432
{Name: "NodeAffinity"},
433-
{Name: "NodeResources"},
433+
{Name: "NodeResourcesFit"},
434434
{Name: "VolumeRestrictions"},
435435
{Name: "TaintToleration"},
436436
{Name: "VolumeZone"},
@@ -525,7 +525,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
525525
{Name: "NodeName"},
526526
{Name: "NodePorts"},
527527
{Name: "NodeAffinity"},
528-
{Name: "NodeResources"},
528+
{Name: "NodeResourcesFit"},
529529
{Name: "VolumeRestrictions"},
530530
{Name: "TaintToleration"},
531531
{Name: "VolumeZone"},
@@ -621,7 +621,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
621621
{Name: "NodeName"},
622622
{Name: "NodePorts"},
623623
{Name: "NodeAffinity"},
624-
{Name: "NodeResources"},
624+
{Name: "NodeResourcesFit"},
625625
{Name: "VolumeRestrictions"},
626626
{Name: "TaintToleration"},
627627
{Name: "VolumeBinding"},
@@ -723,7 +723,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
723723
{Name: "NodeName"},
724724
{Name: "NodePorts"},
725725
{Name: "NodeAffinity"},
726-
{Name: "NodeResources"},
726+
{Name: "NodeResourcesFit"},
727727
{Name: "VolumeRestrictions"},
728728
{Name: "TaintToleration"},
729729
{Name: "VolumeBinding"},
@@ -838,7 +838,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
838838
{Name: "NodeName"},
839839
{Name: "NodePorts"},
840840
{Name: "NodeAffinity"},
841-
{Name: "NodeResources"},
841+
{Name: "NodeResourcesFit"},
842842
{Name: "VolumeRestrictions"},
843843
{Name: "TaintToleration"},
844844
{Name: "VolumeBinding"},
@@ -954,7 +954,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
954954
{Name: "NodeName"},
955955
{Name: "NodePorts"},
956956
{Name: "NodeAffinity"},
957-
{Name: "NodeResources"},
957+
{Name: "NodeResourcesFit"},
958958
{Name: "VolumeRestrictions"},
959959
{Name: "TaintToleration"},
960960
{Name: "NodeVolumeLimits"},
@@ -1071,7 +1071,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
10711071
{Name: "NodeName"},
10721072
{Name: "NodePorts"},
10731073
{Name: "NodeAffinity"},
1074-
{Name: "NodeResources"},
1074+
{Name: "NodeResourcesFit"},
10751075
{Name: "VolumeRestrictions"},
10761076
{Name: "TaintToleration"},
10771077
{Name: "NodeVolumeLimits"},
@@ -1192,7 +1192,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
11921192
{Name: "NodeName"},
11931193
{Name: "NodePorts"},
11941194
{Name: "NodeAffinity"},
1195-
{Name: "NodeResources"},
1195+
{Name: "NodeResourcesFit"},
11961196
{Name: "VolumeRestrictions"},
11971197
{Name: "TaintToleration"},
11981198
{Name: "NodeVolumeLimits"},
@@ -1230,13 +1230,13 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
12301230
seenPredicates := sets.NewString()
12311231
seenPriorities := sets.NewString()
12321232
mandatoryPredicates := sets.NewString()
1233-
generalPredicateFilters := []string{"NodeResources", "NodeName", "NodePorts", "NodeAffinity"}
1233+
generalPredicateFilters := []string{"NodeResourcesFit", "NodeName", "NodePorts", "NodeAffinity"}
12341234
filterToPredicateMap := map[string]string{
12351235
"NodeUnschedulable": "CheckNodeUnschedulable",
12361236
"TaintToleration": "PodToleratesNodeTaints",
12371237
"NodeName": "HostName",
12381238
"NodePorts": "PodFitsHostPorts",
1239-
"NodeResources": "PodFitsResources",
1239+
"NodeResourcesFit": "PodFitsResources",
12401240
"NodeAffinity": "MatchNodeSelector",
12411241
"VolumeBinding": "CheckVolumeBinding",
12421242
"VolumeRestrictions": "NoDiskConflict",

pkg/scheduler/framework/plugins/default_registry.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ func NewDefaultRegistry(args *RegistryArgs) framework.Registry {
5555
return framework.Registry{
5656
imagelocality.Name: imagelocality.New,
5757
tainttoleration.Name: tainttoleration.New,
58-
noderesources.Name: noderesources.New,
5958
nodename.Name: nodename.New,
6059
nodeports.Name: nodeports.New,
6160
nodepreferavoidpods.Name: nodepreferavoidpods.New,
6261
nodeaffinity.Name: nodeaffinity.New,
6362
podtopologyspread.Name: podtopologyspread.New,
6463
nodeunschedulable.Name: nodeunschedulable.New,
64+
noderesources.FitName: noderesources.NewFit,
6565
noderesources.BalancedAllocationName: noderesources.NewBalancedAllocation,
6666
noderesources.MostAllocatedName: noderesources.NewMostAllocated,
6767
noderesources.LeastAllocatedName: noderesources.NewLeastAllocated,
@@ -105,7 +105,7 @@ func NewDefaultConfigProducerRegistry() *ConfigProducerRegistry {
105105
registry.RegisterPredicate(predicates.GeneralPred,
106106
func(_ ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
107107
// GeneralPredicate is a combination of predicates.
108-
plugins.Filter = appendToPluginSet(plugins.Filter, noderesources.Name, nil)
108+
plugins.Filter = appendToPluginSet(plugins.Filter, noderesources.FitName, nil)
109109
plugins.Filter = appendToPluginSet(plugins.Filter, nodename.Name, nil)
110110
plugins.Filter = appendToPluginSet(plugins.Filter, nodeports.Name, nil)
111111
plugins.Filter = appendToPluginSet(plugins.Filter, nodeaffinity.Name, nil)
@@ -118,7 +118,7 @@ func NewDefaultConfigProducerRegistry() *ConfigProducerRegistry {
118118
})
119119
registry.RegisterPredicate(predicates.PodFitsResourcesPred,
120120
func(_ ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
121-
plugins.Filter = appendToPluginSet(plugins.Filter, noderesources.Name, nil)
121+
plugins.Filter = appendToPluginSet(plugins.Filter, noderesources.FitName, nil)
122122
return
123123
})
124124
registry.RegisterPredicate(predicates.HostNamePred,

pkg/scheduler/framework/plugins/noderesources/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ go_library(
44
name = "go_default_library",
55
srcs = [
66
"balanced_allocation.go",
7+
"fit.go",
78
"least_allocated.go",
89
"most_allocated.go",
9-
"node_resources.go",
1010
"test_util.go",
1111
],
1212
importpath = "k8s.io/kubernetes/pkg/scheduler/framework/plugins/noderesources",
@@ -42,9 +42,9 @@ go_test(
4242
name = "go_default_test",
4343
srcs = [
4444
"balanced_allocation_test.go",
45+
"fit_test.go",
4546
"least_allocated_test.go",
4647
"most_allocated_test.go",
47-
"node_resources_test.go",
4848
],
4949
embed = [":go_default_library"],
5050
deps = [

pkg/scheduler/framework/plugins/noderesources/node_resources.go renamed to pkg/scheduler/framework/plugins/noderesources/fit.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ import (
2828
"k8s.io/kubernetes/pkg/scheduler/nodeinfo"
2929
)
3030

31-
// NodeResources is a plugin that checks if a node has sufficient resources.
32-
type NodeResources struct{}
31+
// Fit is a plugin that checks if a node has sufficient resources.
32+
type Fit struct{}
3333

34-
var _ framework.FilterPlugin = &NodeResources{}
34+
var _ framework.FilterPlugin = &Fit{}
3535

36-
// Name is the name of the plugin used in the plugin registry and configurations.
37-
const Name = "NodeResources"
36+
// FitName is the name of the plugin used in the plugin registry and configurations.
37+
const FitName = "NodeResourcesFit"
3838

3939
// Name returns name of the plugin. It is used in logs, etc.
40-
func (pl *NodeResources) Name() string {
41-
return Name
40+
func (f *Fit) Name() string {
41+
return FitName
4242
}
4343

4444
// Filter invoked at the filter extension point.
45-
func (pl *NodeResources) Filter(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod, nodeInfo *nodeinfo.NodeInfo) *framework.Status {
45+
func (f *Fit) Filter(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod, nodeInfo *nodeinfo.NodeInfo) *framework.Status {
4646
meta, ok := migration.PredicateMetadata(cycleState).(predicates.PredicateMetadata)
4747
if !ok {
4848
return migration.ErrorToFrameworkStatus(fmt.Errorf("%+v convert to predicates.PredicateMetadata error", cycleState))
@@ -51,7 +51,7 @@ func (pl *NodeResources) Filter(ctx context.Context, cycleState *framework.Cycle
5151
return migration.PredicateResultToFrameworkStatus(reasons, err)
5252
}
5353

54-
// New initializes a new plugin and returns it.
55-
func New(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
56-
return &NodeResources{}, nil
54+
// NewFit initializes a new plugin and returns it.
55+
func NewFit(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
56+
return &Fit{}, nil
5757
}

pkg/scheduler/framework/plugins/noderesources/node_resources_test.go renamed to pkg/scheduler/framework/plugins/noderesources/fit_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func newResourceOverheadPod(pod *v1.Pod, overhead v1.ResourceList) *v1.Pod {
8989
pod.Spec.Overhead = overhead
9090
return pod
9191
}
92-
func TestNodeResources(t *testing.T) {
92+
func TestNodeResourcesFit(t *testing.T) {
9393
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodOverhead, true)()
9494

9595
enoughPodsTests := []struct {
@@ -350,7 +350,7 @@ func TestNodeResources(t *testing.T) {
350350
node := v1.Node{Status: v1.NodeStatus{Capacity: makeResources(10, 20, 32, 5, 20, 5).Capacity, Allocatable: makeAllocatableResources(10, 20, 32, 5, 20, 5)}}
351351
test.nodeInfo.SetNode(&node)
352352

353-
p, _ := New(nil, nil)
353+
p, _ := NewFit(nil, nil)
354354
gotStatus := p.(framework.FilterPlugin).Filter(context.Background(), state, test.pod, test.nodeInfo)
355355
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
356356
t.Errorf("status does not match: %v, want: %v", gotStatus, test.wantStatus)
@@ -403,7 +403,7 @@ func TestNodeResources(t *testing.T) {
403403
node := v1.Node{Status: v1.NodeStatus{Capacity: v1.ResourceList{}, Allocatable: makeAllocatableResources(10, 20, 1, 0, 0, 0)}}
404404
test.nodeInfo.SetNode(&node)
405405

406-
p, _ := New(nil, nil)
406+
p, _ := NewFit(nil, nil)
407407
gotStatus := p.(framework.FilterPlugin).Filter(context.Background(), state, test.pod, test.nodeInfo)
408408
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
409409
t.Errorf("status does not match: %v, want: %v", gotStatus, test.wantStatus)
@@ -454,7 +454,7 @@ func TestNodeResources(t *testing.T) {
454454
node := v1.Node{Status: v1.NodeStatus{Capacity: makeResources(10, 20, 32, 5, 20, 5).Capacity, Allocatable: makeAllocatableResources(10, 20, 32, 5, 20, 5)}}
455455
test.nodeInfo.SetNode(&node)
456456

457-
p, _ := New(nil, nil)
457+
p, _ := NewFit(nil, nil)
458458
gotStatus := p.(framework.FilterPlugin).Filter(context.Background(), state, test.pod, test.nodeInfo)
459459
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
460460
t.Errorf("status does not match: %v, want: %v", gotStatus, test.wantStatus)

test/integration/scheduler/scheduler_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
141141
expectedPlugins: map[string][]kubeschedulerconfig.Plugin{
142142
"FilterPlugin": {
143143
{Name: "NodeUnschedulable"},
144-
{Name: "NodeResources"},
144+
{Name: "NodeResourcesFit"},
145145
{Name: "NodeName"},
146146
{Name: "NodePorts"},
147147
{Name: "NodeAffinity"},
@@ -221,7 +221,7 @@ kind: Policy
221221
expectedPlugins: map[string][]kubeschedulerconfig.Plugin{
222222
"FilterPlugin": {
223223
{Name: "NodeUnschedulable"},
224-
{Name: "NodeResources"},
224+
{Name: "NodeResourcesFit"},
225225
{Name: "NodeName"},
226226
{Name: "NodePorts"},
227227
{Name: "NodeAffinity"},

0 commit comments

Comments
 (0)