diff --git a/pkg/scheduler/core/extender_test.go b/pkg/scheduler/core/extender_test.go index 919fa283136..b6027ab13c2 100644 --- a/pkg/scheduler/core/extender_test.go +++ b/pkg/scheduler/core/extender_test.go @@ -63,7 +63,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) { Predicates: []st.FitPredicate{st.ErrorPredicateExtender}, }, }, - nodes: []string{"machine1", "machine2"}, + nodes: []string{"node1", "node2"}, expectsErr: true, name: "test 1", }, @@ -81,7 +81,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) { Predicates: []st.FitPredicate{st.FalsePredicateExtender}, }, }, - nodes: []string{"machine1", "machine2"}, + nodes: []string{"node1", "node2"}, expectsErr: true, name: "test 2", }, @@ -96,12 +96,12 @@ func TestGenericSchedulerWithExtenders(t *testing.T) { Predicates: []st.FitPredicate{st.TruePredicateExtender}, }, { - Predicates: []st.FitPredicate{st.Machine1PredicateExtender}, + Predicates: []st.FitPredicate{st.Node1PredicateExtender}, }, }, - nodes: []string{"machine1", "machine2"}, + nodes: []string{"node1", "node2"}, expectedResult: ScheduleResult{ - SuggestedHost: "machine1", + SuggestedHost: "node1", EvaluatedNodes: 2, FeasibleNodes: 1, }, @@ -115,13 +115,13 @@ func TestGenericSchedulerWithExtenders(t *testing.T) { }, extenders: []st.FakeExtender{ { - Predicates: []st.FitPredicate{st.Machine2PredicateExtender}, + Predicates: []st.FitPredicate{st.Node2PredicateExtender}, }, { - Predicates: []st.FitPredicate{st.Machine1PredicateExtender}, + Predicates: []st.FitPredicate{st.Node1PredicateExtender}, }, }, - nodes: []string{"machine1", "machine2"}, + nodes: []string{"node1", "node2"}, expectsErr: true, name: "test 4", }, @@ -138,9 +138,9 @@ func TestGenericSchedulerWithExtenders(t *testing.T) { Weight: 1, }, }, - nodes: []string{"machine1"}, + nodes: []string{"node1"}, expectedResult: ScheduleResult{ - SuggestedHost: "machine1", + SuggestedHost: "node1", EvaluatedNodes: 1, FeasibleNodes: 1, }, @@ -155,18 +155,18 @@ func TestGenericSchedulerWithExtenders(t *testing.T) { extenders: []st.FakeExtender{ { Predicates: []st.FitPredicate{st.TruePredicateExtender}, - Prioritizers: []st.PriorityConfig{{Function: st.Machine1PrioritizerExtender, Weight: 10}}, + Prioritizers: []st.PriorityConfig{{Function: st.Node1PrioritizerExtender, Weight: 10}}, Weight: 1, }, { Predicates: []st.FitPredicate{st.TruePredicateExtender}, - Prioritizers: []st.PriorityConfig{{Function: st.Machine2PrioritizerExtender, Weight: 10}}, + Prioritizers: []st.PriorityConfig{{Function: st.Node2PrioritizerExtender, Weight: 10}}, Weight: 5, }, }, - nodes: []string{"machine1", "machine2"}, + nodes: []string{"node1", "node2"}, expectedResult: ScheduleResult{ - SuggestedHost: "machine2", + SuggestedHost: "node2", EvaluatedNodes: 2, FeasibleNodes: 2, }, @@ -175,23 +175,23 @@ func TestGenericSchedulerWithExtenders(t *testing.T) { { registerPlugins: []st.RegisterPluginFunc{ st.RegisterFilterPlugin("TrueFilter", st.NewTrueFilterPlugin), - st.RegisterScorePlugin("Machine2Prioritizer", st.NewMachine2PrioritizerPlugin(), 20), + st.RegisterScorePlugin("Node2Prioritizer", st.NewNode2PrioritizerPlugin(), 20), st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New), st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New), }, extenders: []st.FakeExtender{ { Predicates: []st.FitPredicate{st.TruePredicateExtender}, - Prioritizers: []st.PriorityConfig{{Function: st.Machine1PrioritizerExtender, Weight: 10}}, + Prioritizers: []st.PriorityConfig{{Function: st.Node1PrioritizerExtender, Weight: 10}}, Weight: 1, }, }, - nodes: []string{"machine1", "machine2"}, + nodes: []string{"node1", "node2"}, expectedResult: ScheduleResult{ - SuggestedHost: "machine2", + SuggestedHost: "node2", EvaluatedNodes: 2, FeasibleNodes: 2, - }, // machine2 has higher score + }, // node2 has higher score name: "test 7", }, { @@ -204,7 +204,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) { // errorPrioritizerExtender. registerPlugins: []st.RegisterPluginFunc{ st.RegisterFilterPlugin("TrueFilter", st.NewTrueFilterPlugin), - st.RegisterScorePlugin("Machine2Prioritizer", st.NewMachine2PrioritizerPlugin(), 1), + st.RegisterScorePlugin("Node2Prioritizer", st.NewNode2PrioritizerPlugin(), 1), st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New), st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New), }, @@ -215,13 +215,13 @@ func TestGenericSchedulerWithExtenders(t *testing.T) { UnInterested: true, }, }, - nodes: []string{"machine1", "machine2"}, + nodes: []string{"node1", "node2"}, expectsErr: false, expectedResult: ScheduleResult{ - SuggestedHost: "machine2", + SuggestedHost: "node2", EvaluatedNodes: 2, FeasibleNodes: 2, - }, // machine2 has higher score + }, // node2 has higher score name: "test 8", }, { @@ -241,13 +241,13 @@ func TestGenericSchedulerWithExtenders(t *testing.T) { Ignorable: true, }, { - Predicates: []st.FitPredicate{st.Machine1PredicateExtender}, + Predicates: []st.FitPredicate{st.Node1PredicateExtender}, }, }, - nodes: []string{"machine1", "machine2"}, + nodes: []string{"node1", "node2"}, expectsErr: false, expectedResult: ScheduleResult{ - SuggestedHost: "machine1", + SuggestedHost: "node1", EvaluatedNodes: 2, FeasibleNodes: 1, }, diff --git a/pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go b/pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go index 5db655f0165..fe8b7a97949 100644 --- a/pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go +++ b/pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go @@ -176,20 +176,20 @@ func TestPostFilter(t *testing.T) { name: "preemption result filtered out by extenders", pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Obj(), pods: []*v1.Pod{ - st.MakePod().Name("p1").UID("p1").Node("machine1").Obj(), - st.MakePod().Name("p2").UID("p2").Node("machine2").Obj(), + st.MakePod().Name("p1").UID("p1").Node("node1").Obj(), + st.MakePod().Name("p2").UID("p2").Node("node2").Obj(), }, nodes: []*v1.Node{ - st.MakeNode().Name("machine1").Capacity(onePodRes).Obj(), - st.MakeNode().Name("machine2").Capacity(onePodRes).Obj(), + st.MakeNode().Name("node1").Capacity(onePodRes).Obj(), + st.MakeNode().Name("node2").Capacity(onePodRes).Obj(), }, filteredNodesStatuses: framework.NodeToStatusMap{ - "machine1": framework.NewStatus(framework.Unschedulable), - "machine2": framework.NewStatus(framework.Unschedulable), + "node1": framework.NewStatus(framework.Unschedulable), + "node2": framework.NewStatus(framework.Unschedulable), }, - extender: &st.FakeExtender{Predicates: []st.FitPredicate{st.Machine1PredicateExtender}}, + extender: &st.FakeExtender{Predicates: []st.FitPredicate{st.Node1PredicateExtender}}, wantResult: &framework.PostFilterResult{ - NominatedNodeName: "machine1", + NominatedNodeName: "node1", }, wantStatus: framework.NewStatus(framework.Success), }, @@ -258,7 +258,7 @@ func TestDryRunPreemption(t *testing.T) { expectedNumFilterCalled int32 }{ { - name: "a pod that does not fit on any machine", + name: "a pod that does not fit on any node", registerPlugins: []st.RegisterPluginFunc{ st.RegisterFilterPlugin("FalseFilter", st.NewFalseFilterPlugin), }, @@ -289,7 +289,7 @@ func TestDryRunPreemption(t *testing.T) { expectedNumFilterCalled: 4, }, { - name: "a pod that fits on one machine with no preemption", + name: "a pod that fits on one node with no preemption", registerPlugins: []st.RegisterPluginFunc{ st.RegisterFilterPlugin("MatchFilter", st.NewMatchFilterPlugin), }, @@ -306,7 +306,7 @@ func TestDryRunPreemption(t *testing.T) { expectedNumFilterCalled: 3, }, { - name: "a pod that fits on both machines when lower priority pods are preempted", + name: "a pod that fits on both nodes when lower priority pods are preempted", registerPlugins: []st.RegisterPluginFunc{ st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"), }, @@ -333,7 +333,7 @@ func TestDryRunPreemption(t *testing.T) { expectedNumFilterCalled: 4, }, { - name: "a pod that would fit on the machines, but other pods running are higher priority, no preemption would happen", + name: "a pod that would fit on the nodes, but other pods running are higher priority, no preemption would happen", registerPlugins: []st.RegisterPluginFunc{ st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"), }, @@ -741,7 +741,7 @@ func TestSelectBestCandidate(t *testing.T) { expected: []string{"node1", "node2"}, }, { - name: "machine with min highest priority pod is picked", + name: "node with min highest priority pod is picked", registerPlugin: st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"), nodeNames: []string{"node1", "node2", "node3"}, pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Req(veryLargeRes).Obj(), @@ -829,7 +829,7 @@ func TestSelectBestCandidate(t *testing.T) { expected: []string{"node1"}, }, { - name: "same priority, same number of victims, different start time for each machine's pod", + name: "same priority, same number of victims, different start time for each node's pod", registerPlugin: st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"), nodeNames: []string{"node1", "node2", "node3"}, pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Req(veryLargeRes).Obj(), @@ -1137,20 +1137,20 @@ func TestPreempt(t *testing.T) { expectedPods: []string{"p-b1"}, }, { - name: "Scheduler extenders allow only machine1, otherwise machine3 would have been chosen", + name: "Scheduler extenders allow only node1, otherwise node3 would have been chosen", pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Req(veryLargeRes).PreemptionPolicy(v1.PreemptLowerPriority).Obj(), pods: []*v1.Pod{ - st.MakePod().Name("p1.1").UID("p1.1").Node("machine1").Priority(midPriority).Req(smallRes).Obj(), - st.MakePod().Name("p1.2").UID("p1.2").Node("machine1").Priority(lowPriority).Req(smallRes).Obj(), - st.MakePod().Name("p2.1").UID("p2.1").Node("machine3").Priority(midPriority).Req(largeRes).Obj(), + st.MakePod().Name("p1.1").UID("p1.1").Node("node1").Priority(midPriority).Req(smallRes).Obj(), + st.MakePod().Name("p1.2").UID("p1.2").Node("node1").Priority(lowPriority).Req(smallRes).Obj(), + st.MakePod().Name("p2.1").UID("p2.1").Node("node3").Priority(midPriority).Req(largeRes).Obj(), }, - nodeNames: []string{"machine1", "machine2", "machine3"}, + nodeNames: []string{"node1", "node2", "node3"}, extenders: []*st.FakeExtender{ {Predicates: []st.FitPredicate{st.TruePredicateExtender}}, - {Predicates: []st.FitPredicate{st.Machine1PredicateExtender}}, + {Predicates: []st.FitPredicate{st.Node1PredicateExtender}}, }, registerPlugin: st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"), - expectedNode: "machine1", + expectedNode: "node1", expectedPods: []string{"p1.1", "p1.2"}, }, { @@ -1170,38 +1170,38 @@ func TestPreempt(t *testing.T) { expectedPods: []string{}, }, { - name: "One scheduler extender allows only machine1, the other returns error but ignorable. Only machine1 would be chosen", + name: "One scheduler extender allows only node1, the other returns error but ignorable. Only node1 would be chosen", pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Req(veryLargeRes).PreemptionPolicy(v1.PreemptLowerPriority).Obj(), pods: []*v1.Pod{ - st.MakePod().Name("p1.1").UID("p1.1").Node("machine1").Priority(midPriority).Req(smallRes).Obj(), - st.MakePod().Name("p1.2").UID("p1.2").Node("machine1").Priority(lowPriority).Req(smallRes).Obj(), - st.MakePod().Name("p2.1").UID("p2.1").Node("machine2").Priority(midPriority).Req(largeRes).Obj(), + st.MakePod().Name("p1.1").UID("p1.1").Node("node1").Priority(midPriority).Req(smallRes).Obj(), + st.MakePod().Name("p1.2").UID("p1.2").Node("node1").Priority(lowPriority).Req(smallRes).Obj(), + st.MakePod().Name("p2.1").UID("p2.1").Node("node2").Priority(midPriority).Req(largeRes).Obj(), }, - nodeNames: []string{"machine1", "machine2", "machine3"}, + nodeNames: []string{"node1", "node2", "node3"}, extenders: []*st.FakeExtender{ {Predicates: []st.FitPredicate{st.ErrorPredicateExtender}, Ignorable: true}, - {Predicates: []st.FitPredicate{st.Machine1PredicateExtender}}, + {Predicates: []st.FitPredicate{st.Node1PredicateExtender}}, }, registerPlugin: st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"), - expectedNode: "machine1", + expectedNode: "node1", expectedPods: []string{"p1.1", "p1.2"}, }, { - name: "One scheduler extender allows only machine1, but it is not interested in given pod, otherwise machine1 would have been chosen", + name: "One scheduler extender allows only node1, but it is not interested in given pod, otherwise node1 would have been chosen", pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Req(veryLargeRes).PreemptionPolicy(v1.PreemptLowerPriority).Obj(), pods: []*v1.Pod{ - st.MakePod().Name("p1.1").UID("p1.1").Node("machine1").Priority(midPriority).Req(smallRes).Obj(), - st.MakePod().Name("p1.2").UID("p1.2").Node("machine1").Priority(lowPriority).Req(smallRes).Obj(), - st.MakePod().Name("p2.1").UID("p2.1").Node("machine2").Priority(midPriority).Req(largeRes).Obj(), + st.MakePod().Name("p1.1").UID("p1.1").Node("node1").Priority(midPriority).Req(smallRes).Obj(), + st.MakePod().Name("p1.2").UID("p1.2").Node("node1").Priority(lowPriority).Req(smallRes).Obj(), + st.MakePod().Name("p2.1").UID("p2.1").Node("node2").Priority(midPriority).Req(largeRes).Obj(), }, - nodeNames: []string{"machine1", "machine2"}, + nodeNames: []string{"node1", "node2"}, extenders: []*st.FakeExtender{ - {Predicates: []st.FitPredicate{st.Machine1PredicateExtender}, UnInterested: true}, + {Predicates: []st.FitPredicate{st.Node1PredicateExtender}, UnInterested: true}, {Predicates: []st.FitPredicate{st.TruePredicateExtender}}, }, registerPlugin: st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"), - // sum of priorities of all victims on machine1 is larger than machine2, machine2 is chosen. - expectedNode: "machine2", + //sum of priorities of all victims on node1 is larger than node2, node2 is chosen. + expectedNode: "node2", expectedPods: []string{"p2.1"}, }, { diff --git a/pkg/scheduler/testing/fake_extender.go b/pkg/scheduler/testing/fake_extender.go index e1e89745e0c..ab45960d4c3 100644 --- a/pkg/scheduler/testing/fake_extender.go +++ b/pkg/scheduler/testing/fake_extender.go @@ -57,19 +57,19 @@ func TruePredicateExtender(pod *v1.Pod, node *v1.Node) (bool, error) { return true, nil } -// Machine1PredicateExtender implements FitPredicate function to return true -// when the given node's name is "machine1"; otherwise return false. -func Machine1PredicateExtender(pod *v1.Pod, node *v1.Node) (bool, error) { - if node.Name == "machine1" { +// Node1PredicateExtender implements FitPredicate function to return true +// when the given node's name is "node1"; otherwise return false. +func Node1PredicateExtender(pod *v1.Pod, node *v1.Node) (bool, error) { + if node.Name == "node1" { return true, nil } return false, nil } -// Machine2PredicateExtender implements FitPredicate function to return true -// when the given node's name is "machine2"; otherwise return false. -func Machine2PredicateExtender(pod *v1.Pod, node *v1.Node) (bool, error) { - if node.Name == "machine2" { +// Node2PredicateExtender implements FitPredicate function to return true +// when the given node's name is "node2"; otherwise return false. +func Node2PredicateExtender(pod *v1.Pod, node *v1.Node) (bool, error) { + if node.Name == "node2" { return true, nil } return false, nil @@ -80,13 +80,13 @@ func ErrorPrioritizerExtender(pod *v1.Pod, nodes []*v1.Node) (*framework.NodeSco return &framework.NodeScoreList{}, fmt.Errorf("some error") } -// Machine1PrioritizerExtender implements PriorityFunc function to give score 10 -// if the given node's name is "machine1"; otherwise score 1. -func Machine1PrioritizerExtender(pod *v1.Pod, nodes []*v1.Node) (*framework.NodeScoreList, error) { +// Node1PrioritizerExtender implements PriorityFunc function to give score 10 +// if the given node's name is "node1"; otherwise score 1. +func Node1PrioritizerExtender(pod *v1.Pod, nodes []*v1.Node) (*framework.NodeScoreList, error) { result := framework.NodeScoreList{} for _, node := range nodes { score := 1 - if node.Name == "machine1" { + if node.Name == "node1" { score = 10 } result = append(result, framework.NodeScore{Name: node.Name, Score: int64(score)}) @@ -94,13 +94,13 @@ func Machine1PrioritizerExtender(pod *v1.Pod, nodes []*v1.Node) (*framework.Node return &result, nil } -// Machine2PrioritizerExtender implements PriorityFunc function to give score 10 -// if the given node's name is "machine2"; otherwise score 1. -func Machine2PrioritizerExtender(pod *v1.Pod, nodes []*v1.Node) (*framework.NodeScoreList, error) { +// Node2PrioritizerExtender implements PriorityFunc function to give score 10 +// if the given node's name is "node2"; otherwise score 1. +func Node2PrioritizerExtender(pod *v1.Pod, nodes []*v1.Node) (*framework.NodeScoreList, error) { result := framework.NodeScoreList{} for _, node := range nodes { score := 1 - if node.Name == "machine2" { + if node.Name == "node2" { score = 10 } result = append(result, framework.NodeScore{Name: node.Name, Score: int64(score)}) @@ -108,31 +108,31 @@ func Machine2PrioritizerExtender(pod *v1.Pod, nodes []*v1.Node) (*framework.Node return &result, nil } -type machine2PrioritizerPlugin struct{} +type node2PrioritizerPlugin struct{} -// NewMachine2PrioritizerPlugin returns a factory function to build machine2PrioritizerPlugin. -func NewMachine2PrioritizerPlugin() frameworkruntime.PluginFactory { +// NewNode2PrioritizerPlugin returns a factory function to build node2PrioritizerPlugin. +func NewNode2PrioritizerPlugin() frameworkruntime.PluginFactory { return func(_ runtime.Object, _ framework.FrameworkHandle) (framework.Plugin, error) { - return &machine2PrioritizerPlugin{}, nil + return &node2PrioritizerPlugin{}, nil } } // Name returns name of the plugin. -func (pl *machine2PrioritizerPlugin) Name() string { - return "Machine2Prioritizer" +func (pl *node2PrioritizerPlugin) Name() string { + return "Node2Prioritizer" } -// Score return score 100 if the given nodeName is "machine2"; otherwise return score 10. -func (pl *machine2PrioritizerPlugin) Score(_ context.Context, _ *framework.CycleState, _ *v1.Pod, nodeName string) (int64, *framework.Status) { +// Score return score 100 if the given nodeName is "node2"; otherwise return score 10. +func (pl *node2PrioritizerPlugin) Score(_ context.Context, _ *framework.CycleState, _ *v1.Pod, nodeName string) (int64, *framework.Status) { score := 10 - if nodeName == "machine2" { + if nodeName == "node2" { score = 100 } return int64(score), nil } // ScoreExtensions returns nil. -func (pl *machine2PrioritizerPlugin) ScoreExtensions() framework.ScoreExtensions { +func (pl *node2PrioritizerPlugin) ScoreExtensions() framework.ScoreExtensions { return nil }