mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-15 06:43:54 +00:00
Change the node name from "machine" to "node"
Latest change on master rename the node name from "machine" to "node" but haven't update all the affected code, which causes some of testcases invalid. Signed-off-by: Dave Chen <dave.chen@arm.com>
This commit is contained in:
parent
dd649bb7ef
commit
a1b2a7765d
@ -63,7 +63,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
|
|||||||
Predicates: []st.FitPredicate{st.ErrorPredicateExtender},
|
Predicates: []st.FitPredicate{st.ErrorPredicateExtender},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
nodes: []string{"machine1", "machine2"},
|
nodes: []string{"node1", "node2"},
|
||||||
expectsErr: true,
|
expectsErr: true,
|
||||||
name: "test 1",
|
name: "test 1",
|
||||||
},
|
},
|
||||||
@ -81,7 +81,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
|
|||||||
Predicates: []st.FitPredicate{st.FalsePredicateExtender},
|
Predicates: []st.FitPredicate{st.FalsePredicateExtender},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
nodes: []string{"machine1", "machine2"},
|
nodes: []string{"node1", "node2"},
|
||||||
expectsErr: true,
|
expectsErr: true,
|
||||||
name: "test 2",
|
name: "test 2",
|
||||||
},
|
},
|
||||||
@ -96,12 +96,12 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
|
|||||||
Predicates: []st.FitPredicate{st.TruePredicateExtender},
|
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{
|
expectedResult: ScheduleResult{
|
||||||
SuggestedHost: "machine1",
|
SuggestedHost: "node1",
|
||||||
EvaluatedNodes: 2,
|
EvaluatedNodes: 2,
|
||||||
FeasibleNodes: 1,
|
FeasibleNodes: 1,
|
||||||
},
|
},
|
||||||
@ -115,13 +115,13 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
|
|||||||
},
|
},
|
||||||
extenders: []st.FakeExtender{
|
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,
|
expectsErr: true,
|
||||||
name: "test 4",
|
name: "test 4",
|
||||||
},
|
},
|
||||||
@ -138,9 +138,9 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
|
|||||||
Weight: 1,
|
Weight: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
nodes: []string{"machine1"},
|
nodes: []string{"node1"},
|
||||||
expectedResult: ScheduleResult{
|
expectedResult: ScheduleResult{
|
||||||
SuggestedHost: "machine1",
|
SuggestedHost: "node1",
|
||||||
EvaluatedNodes: 1,
|
EvaluatedNodes: 1,
|
||||||
FeasibleNodes: 1,
|
FeasibleNodes: 1,
|
||||||
},
|
},
|
||||||
@ -155,18 +155,18 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
|
|||||||
extenders: []st.FakeExtender{
|
extenders: []st.FakeExtender{
|
||||||
{
|
{
|
||||||
Predicates: []st.FitPredicate{st.TruePredicateExtender},
|
Predicates: []st.FitPredicate{st.TruePredicateExtender},
|
||||||
Prioritizers: []st.PriorityConfig{{Function: st.Machine1PrioritizerExtender, Weight: 10}},
|
Prioritizers: []st.PriorityConfig{{Function: st.Node1PrioritizerExtender, Weight: 10}},
|
||||||
Weight: 1,
|
Weight: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Predicates: []st.FitPredicate{st.TruePredicateExtender},
|
Predicates: []st.FitPredicate{st.TruePredicateExtender},
|
||||||
Prioritizers: []st.PriorityConfig{{Function: st.Machine2PrioritizerExtender, Weight: 10}},
|
Prioritizers: []st.PriorityConfig{{Function: st.Node2PrioritizerExtender, Weight: 10}},
|
||||||
Weight: 5,
|
Weight: 5,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
nodes: []string{"machine1", "machine2"},
|
nodes: []string{"node1", "node2"},
|
||||||
expectedResult: ScheduleResult{
|
expectedResult: ScheduleResult{
|
||||||
SuggestedHost: "machine2",
|
SuggestedHost: "node2",
|
||||||
EvaluatedNodes: 2,
|
EvaluatedNodes: 2,
|
||||||
FeasibleNodes: 2,
|
FeasibleNodes: 2,
|
||||||
},
|
},
|
||||||
@ -175,23 +175,23 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
|
|||||||
{
|
{
|
||||||
registerPlugins: []st.RegisterPluginFunc{
|
registerPlugins: []st.RegisterPluginFunc{
|
||||||
st.RegisterFilterPlugin("TrueFilter", st.NewTrueFilterPlugin),
|
st.RegisterFilterPlugin("TrueFilter", st.NewTrueFilterPlugin),
|
||||||
st.RegisterScorePlugin("Machine2Prioritizer", st.NewMachine2PrioritizerPlugin(), 20),
|
st.RegisterScorePlugin("Node2Prioritizer", st.NewNode2PrioritizerPlugin(), 20),
|
||||||
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
||||||
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
||||||
},
|
},
|
||||||
extenders: []st.FakeExtender{
|
extenders: []st.FakeExtender{
|
||||||
{
|
{
|
||||||
Predicates: []st.FitPredicate{st.TruePredicateExtender},
|
Predicates: []st.FitPredicate{st.TruePredicateExtender},
|
||||||
Prioritizers: []st.PriorityConfig{{Function: st.Machine1PrioritizerExtender, Weight: 10}},
|
Prioritizers: []st.PriorityConfig{{Function: st.Node1PrioritizerExtender, Weight: 10}},
|
||||||
Weight: 1,
|
Weight: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
nodes: []string{"machine1", "machine2"},
|
nodes: []string{"node1", "node2"},
|
||||||
expectedResult: ScheduleResult{
|
expectedResult: ScheduleResult{
|
||||||
SuggestedHost: "machine2",
|
SuggestedHost: "node2",
|
||||||
EvaluatedNodes: 2,
|
EvaluatedNodes: 2,
|
||||||
FeasibleNodes: 2,
|
FeasibleNodes: 2,
|
||||||
}, // machine2 has higher score
|
}, // node2 has higher score
|
||||||
name: "test 7",
|
name: "test 7",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -204,7 +204,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
|
|||||||
// errorPrioritizerExtender.
|
// errorPrioritizerExtender.
|
||||||
registerPlugins: []st.RegisterPluginFunc{
|
registerPlugins: []st.RegisterPluginFunc{
|
||||||
st.RegisterFilterPlugin("TrueFilter", st.NewTrueFilterPlugin),
|
st.RegisterFilterPlugin("TrueFilter", st.NewTrueFilterPlugin),
|
||||||
st.RegisterScorePlugin("Machine2Prioritizer", st.NewMachine2PrioritizerPlugin(), 1),
|
st.RegisterScorePlugin("Node2Prioritizer", st.NewNode2PrioritizerPlugin(), 1),
|
||||||
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
||||||
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
||||||
},
|
},
|
||||||
@ -215,13 +215,13 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
|
|||||||
UnInterested: true,
|
UnInterested: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
nodes: []string{"machine1", "machine2"},
|
nodes: []string{"node1", "node2"},
|
||||||
expectsErr: false,
|
expectsErr: false,
|
||||||
expectedResult: ScheduleResult{
|
expectedResult: ScheduleResult{
|
||||||
SuggestedHost: "machine2",
|
SuggestedHost: "node2",
|
||||||
EvaluatedNodes: 2,
|
EvaluatedNodes: 2,
|
||||||
FeasibleNodes: 2,
|
FeasibleNodes: 2,
|
||||||
}, // machine2 has higher score
|
}, // node2 has higher score
|
||||||
name: "test 8",
|
name: "test 8",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -241,13 +241,13 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
|
|||||||
Ignorable: true,
|
Ignorable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Predicates: []st.FitPredicate{st.Machine1PredicateExtender},
|
Predicates: []st.FitPredicate{st.Node1PredicateExtender},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
nodes: []string{"machine1", "machine2"},
|
nodes: []string{"node1", "node2"},
|
||||||
expectsErr: false,
|
expectsErr: false,
|
||||||
expectedResult: ScheduleResult{
|
expectedResult: ScheduleResult{
|
||||||
SuggestedHost: "machine1",
|
SuggestedHost: "node1",
|
||||||
EvaluatedNodes: 2,
|
EvaluatedNodes: 2,
|
||||||
FeasibleNodes: 1,
|
FeasibleNodes: 1,
|
||||||
},
|
},
|
||||||
|
@ -176,20 +176,20 @@ func TestPostFilter(t *testing.T) {
|
|||||||
name: "preemption result filtered out by extenders",
|
name: "preemption result filtered out by extenders",
|
||||||
pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Obj(),
|
pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Obj(),
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
st.MakePod().Name("p1").UID("p1").Node("machine1").Obj(),
|
st.MakePod().Name("p1").UID("p1").Node("node1").Obj(),
|
||||||
st.MakePod().Name("p2").UID("p2").Node("machine2").Obj(),
|
st.MakePod().Name("p2").UID("p2").Node("node2").Obj(),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{
|
nodes: []*v1.Node{
|
||||||
st.MakeNode().Name("machine1").Capacity(onePodRes).Obj(),
|
st.MakeNode().Name("node1").Capacity(onePodRes).Obj(),
|
||||||
st.MakeNode().Name("machine2").Capacity(onePodRes).Obj(),
|
st.MakeNode().Name("node2").Capacity(onePodRes).Obj(),
|
||||||
},
|
},
|
||||||
filteredNodesStatuses: framework.NodeToStatusMap{
|
filteredNodesStatuses: framework.NodeToStatusMap{
|
||||||
"machine1": framework.NewStatus(framework.Unschedulable),
|
"node1": framework.NewStatus(framework.Unschedulable),
|
||||||
"machine2": 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{
|
wantResult: &framework.PostFilterResult{
|
||||||
NominatedNodeName: "machine1",
|
NominatedNodeName: "node1",
|
||||||
},
|
},
|
||||||
wantStatus: framework.NewStatus(framework.Success),
|
wantStatus: framework.NewStatus(framework.Success),
|
||||||
},
|
},
|
||||||
@ -255,7 +255,7 @@ func TestSelectNodesForPreemption(t *testing.T) {
|
|||||||
expectedNumFilterCalled int32
|
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{
|
registerPlugins: []st.RegisterPluginFunc{
|
||||||
st.RegisterFilterPlugin("FalseFilter", st.NewFalseFilterPlugin),
|
st.RegisterFilterPlugin("FalseFilter", st.NewFalseFilterPlugin),
|
||||||
},
|
},
|
||||||
@ -286,7 +286,7 @@ func TestSelectNodesForPreemption(t *testing.T) {
|
|||||||
expectedNumFilterCalled: 4,
|
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{
|
registerPlugins: []st.RegisterPluginFunc{
|
||||||
st.RegisterFilterPlugin("MatchFilter", st.NewMatchFilterPlugin),
|
st.RegisterFilterPlugin("MatchFilter", st.NewMatchFilterPlugin),
|
||||||
},
|
},
|
||||||
@ -302,7 +302,7 @@ func TestSelectNodesForPreemption(t *testing.T) {
|
|||||||
expectedNumFilterCalled: 3,
|
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{
|
registerPlugins: []st.RegisterPluginFunc{
|
||||||
st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"),
|
st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"),
|
||||||
},
|
},
|
||||||
@ -323,7 +323,7 @@ func TestSelectNodesForPreemption(t *testing.T) {
|
|||||||
expectedNumFilterCalled: 4,
|
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{
|
registerPlugins: []st.RegisterPluginFunc{
|
||||||
st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"),
|
st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"),
|
||||||
},
|
},
|
||||||
@ -696,7 +696,7 @@ func TestPickOneNodeForPreemption(t *testing.T) {
|
|||||||
expected: []string{"node1", "node2"},
|
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"),
|
registerPlugin: st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"),
|
||||||
nodeNames: []string{"node1", "node2", "node3"},
|
nodeNames: []string{"node1", "node2", "node3"},
|
||||||
pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Req(veryLargeRes).Obj(),
|
pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Req(veryLargeRes).Obj(),
|
||||||
@ -784,7 +784,7 @@ func TestPickOneNodeForPreemption(t *testing.T) {
|
|||||||
expected: []string{"node1"},
|
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"),
|
registerPlugin: st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"),
|
||||||
nodeNames: []string{"node1", "node2", "node3"},
|
nodeNames: []string{"node1", "node2", "node3"},
|
||||||
pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Req(veryLargeRes).Obj(),
|
pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Req(veryLargeRes).Obj(),
|
||||||
@ -1095,20 +1095,20 @@ func TestPreempt(t *testing.T) {
|
|||||||
expectedPods: []string{"p-b1"},
|
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(),
|
pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Req(veryLargeRes).PreemptionPolicy(v1.PreemptLowerPriority).Obj(),
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
st.MakePod().Name("p1.1").UID("p1.1").Node("machine1").Priority(midPriority).Req(smallRes).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("machine1").Priority(lowPriority).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("machine3").Priority(midPriority).Req(largeRes).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{
|
extenders: []*st.FakeExtender{
|
||||||
{Predicates: []st.FitPredicate{st.TruePredicateExtender}},
|
{Predicates: []st.FitPredicate{st.TruePredicateExtender}},
|
||||||
{Predicates: []st.FitPredicate{st.Machine1PredicateExtender}},
|
{Predicates: []st.FitPredicate{st.Node1PredicateExtender}},
|
||||||
},
|
},
|
||||||
registerPlugin: st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"),
|
registerPlugin: st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"),
|
||||||
expectedNode: "machine1",
|
expectedNode: "node1",
|
||||||
expectedPods: []string{"p1.1", "p1.2"},
|
expectedPods: []string{"p1.1", "p1.2"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1128,38 +1128,38 @@ func TestPreempt(t *testing.T) {
|
|||||||
expectedPods: []string{},
|
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(),
|
pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Req(veryLargeRes).PreemptionPolicy(v1.PreemptLowerPriority).Obj(),
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
st.MakePod().Name("p1.1").UID("p1.1").Node("machine1").Priority(midPriority).Req(smallRes).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("machine1").Priority(lowPriority).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("machine2").Priority(midPriority).Req(largeRes).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{
|
extenders: []*st.FakeExtender{
|
||||||
{Predicates: []st.FitPredicate{st.ErrorPredicateExtender}, Ignorable: true},
|
{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"),
|
registerPlugin: st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"),
|
||||||
expectedNode: "machine1",
|
expectedNode: "node1",
|
||||||
expectedPods: []string{"p1.1", "p1.2"},
|
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(),
|
pod: st.MakePod().Name("p").UID("p").Priority(highPriority).Req(veryLargeRes).PreemptionPolicy(v1.PreemptLowerPriority).Obj(),
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
st.MakePod().Name("p1.1").UID("p1.1").Node("machine1").Priority(midPriority).Req(smallRes).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("machine1").Priority(lowPriority).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("machine2").Priority(midPriority).Req(largeRes).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{
|
extenders: []*st.FakeExtender{
|
||||||
{Predicates: []st.FitPredicate{st.Machine1PredicateExtender}, UnInterested: true},
|
{Predicates: []st.FitPredicate{st.Node1PredicateExtender}, UnInterested: true},
|
||||||
{Predicates: []st.FitPredicate{st.TruePredicateExtender}},
|
{Predicates: []st.FitPredicate{st.TruePredicateExtender}},
|
||||||
},
|
},
|
||||||
registerPlugin: st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"),
|
registerPlugin: st.RegisterPluginAsExtensions(noderesources.FitName, noderesources.NewFit, "Filter", "PreFilter"),
|
||||||
// sum of priorities of all victims on machine1 is larger than machine2, machine2 is chosen.
|
//sum of priorities of all victims on node1 is larger than node2, node2 is chosen.
|
||||||
expectedNode: "machine2",
|
expectedNode: "node2",
|
||||||
expectedPods: []string{"p2.1"},
|
expectedPods: []string{"p2.1"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -57,19 +57,19 @@ func TruePredicateExtender(pod *v1.Pod, node *v1.Node) (bool, error) {
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Machine1PredicateExtender implements FitPredicate function to return true
|
// Node1PredicateExtender implements FitPredicate function to return true
|
||||||
// when the given node's name is "machine1"; otherwise return false.
|
// when the given node's name is "node1"; otherwise return false.
|
||||||
func Machine1PredicateExtender(pod *v1.Pod, node *v1.Node) (bool, error) {
|
func Node1PredicateExtender(pod *v1.Pod, node *v1.Node) (bool, error) {
|
||||||
if node.Name == "machine1" {
|
if node.Name == "node1" {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Machine2PredicateExtender implements FitPredicate function to return true
|
// Node2PredicateExtender implements FitPredicate function to return true
|
||||||
// when the given node's name is "machine2"; otherwise return false.
|
// when the given node's name is "node2"; otherwise return false.
|
||||||
func Machine2PredicateExtender(pod *v1.Pod, node *v1.Node) (bool, error) {
|
func Node2PredicateExtender(pod *v1.Pod, node *v1.Node) (bool, error) {
|
||||||
if node.Name == "machine2" {
|
if node.Name == "node2" {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
return false, 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")
|
return &framework.NodeScoreList{}, fmt.Errorf("some error")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Machine1PrioritizerExtender implements PriorityFunc function to give score 10
|
// Node1PrioritizerExtender implements PriorityFunc function to give score 10
|
||||||
// if the given node's name is "machine1"; otherwise score 1.
|
// if the given node's name is "node1"; otherwise score 1.
|
||||||
func Machine1PrioritizerExtender(pod *v1.Pod, nodes []*v1.Node) (*framework.NodeScoreList, error) {
|
func Node1PrioritizerExtender(pod *v1.Pod, nodes []*v1.Node) (*framework.NodeScoreList, error) {
|
||||||
result := framework.NodeScoreList{}
|
result := framework.NodeScoreList{}
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
score := 1
|
score := 1
|
||||||
if node.Name == "machine1" {
|
if node.Name == "node1" {
|
||||||
score = 10
|
score = 10
|
||||||
}
|
}
|
||||||
result = append(result, framework.NodeScore{Name: node.Name, Score: int64(score)})
|
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
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Machine2PrioritizerExtender implements PriorityFunc function to give score 10
|
// Node2PrioritizerExtender implements PriorityFunc function to give score 10
|
||||||
// if the given node's name is "machine2"; otherwise score 1.
|
// if the given node's name is "node2"; otherwise score 1.
|
||||||
func Machine2PrioritizerExtender(pod *v1.Pod, nodes []*v1.Node) (*framework.NodeScoreList, error) {
|
func Node2PrioritizerExtender(pod *v1.Pod, nodes []*v1.Node) (*framework.NodeScoreList, error) {
|
||||||
result := framework.NodeScoreList{}
|
result := framework.NodeScoreList{}
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
score := 1
|
score := 1
|
||||||
if node.Name == "machine2" {
|
if node.Name == "node2" {
|
||||||
score = 10
|
score = 10
|
||||||
}
|
}
|
||||||
result = append(result, framework.NodeScore{Name: node.Name, Score: int64(score)})
|
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
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type machine2PrioritizerPlugin struct{}
|
type node2PrioritizerPlugin struct{}
|
||||||
|
|
||||||
// NewMachine2PrioritizerPlugin returns a factory function to build machine2PrioritizerPlugin.
|
// NewNode2PrioritizerPlugin returns a factory function to build node2PrioritizerPlugin.
|
||||||
func NewMachine2PrioritizerPlugin() frameworkruntime.PluginFactory {
|
func NewNode2PrioritizerPlugin() frameworkruntime.PluginFactory {
|
||||||
return func(_ runtime.Object, _ framework.FrameworkHandle) (framework.Plugin, error) {
|
return func(_ runtime.Object, _ framework.FrameworkHandle) (framework.Plugin, error) {
|
||||||
return &machine2PrioritizerPlugin{}, nil
|
return &node2PrioritizerPlugin{}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name returns name of the plugin.
|
// Name returns name of the plugin.
|
||||||
func (pl *machine2PrioritizerPlugin) Name() string {
|
func (pl *node2PrioritizerPlugin) Name() string {
|
||||||
return "Machine2Prioritizer"
|
return "Node2Prioritizer"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Score return score 100 if the given nodeName is "machine2"; otherwise return score 10.
|
// Score return score 100 if the given nodeName is "node2"; otherwise return score 10.
|
||||||
func (pl *machine2PrioritizerPlugin) Score(_ context.Context, _ *framework.CycleState, _ *v1.Pod, nodeName string) (int64, *framework.Status) {
|
func (pl *node2PrioritizerPlugin) Score(_ context.Context, _ *framework.CycleState, _ *v1.Pod, nodeName string) (int64, *framework.Status) {
|
||||||
score := 10
|
score := 10
|
||||||
if nodeName == "machine2" {
|
if nodeName == "node2" {
|
||||||
score = 100
|
score = 100
|
||||||
}
|
}
|
||||||
return int64(score), nil
|
return int64(score), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScoreExtensions returns nil.
|
// ScoreExtensions returns nil.
|
||||||
func (pl *machine2PrioritizerPlugin) ScoreExtensions() framework.ScoreExtensions {
|
func (pl *node2PrioritizerPlugin) ScoreExtensions() framework.ScoreExtensions {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user