From 097094e5fa5065eaaab69167373d9ea308fcdd59 Mon Sep 17 00:00:00 2001 From: Guoliang Wang Date: Wed, 23 May 2018 13:56:17 +0800 Subject: [PATCH] Remove unused parameter (pod) --- pkg/scheduler/core/generic_scheduler.go | 4 +- pkg/scheduler/core/generic_scheduler_test.go | 56 +------------------- 2 files changed, 3 insertions(+), 57 deletions(-) diff --git a/pkg/scheduler/core/generic_scheduler.go b/pkg/scheduler/core/generic_scheduler.go index 960054b0d14..98f7acf4c57 100644 --- a/pkg/scheduler/core/generic_scheduler.go +++ b/pkg/scheduler/core/generic_scheduler.go @@ -219,7 +219,7 @@ func (g *genericScheduler) Preempt(pod *v1.Pod, nodeLister algorithm.NodeLister, if len(allNodes) == 0 { return nil, nil, nil, ErrNoNodesAvailable } - potentialNodes := nodesWherePreemptionMightHelp(pod, allNodes, fitError.FailedPredicates) + potentialNodes := nodesWherePreemptionMightHelp(allNodes, fitError.FailedPredicates) if len(potentialNodes) == 0 { glog.V(3).Infof("Preemption will not help schedule pod %v on any node.", pod.Name) // In this case, we should clean-up any existing nominated node name of the pod. @@ -969,7 +969,7 @@ func selectVictimsOnNode( // nodesWherePreemptionMightHelp returns a list of nodes with failed predicates // that may be satisfied by removing pods from the node. -func nodesWherePreemptionMightHelp(pod *v1.Pod, nodes []*v1.Node, failedPredicatesMap FailedPredicateMap) []*v1.Node { +func nodesWherePreemptionMightHelp(nodes []*v1.Node, failedPredicatesMap FailedPredicateMap) []*v1.Node { potentialNodes := []*v1.Node{} for _, node := range nodes { unresolvableReasonExist := false diff --git a/pkg/scheduler/core/generic_scheduler_test.go b/pkg/scheduler/core/generic_scheduler_test.go index 01c6d331ff5..704bb82ca88 100644 --- a/pkg/scheduler/core/generic_scheduler_test.go +++ b/pkg/scheduler/core/generic_scheduler_test.go @@ -1097,7 +1097,6 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) { tests := []struct { name string failedPredMap FailedPredicateMap - pod *v1.Pod expected map[string]bool // set of expected node names. Value is ignored. }{ { @@ -1108,7 +1107,6 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) { "machine3": []algorithm.PredicateFailureReason{algorithmpredicates.ErrTaintsTolerationsNotMatch}, "machine4": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeLabelPresenceViolated}, }, - pod: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "pod1", UID: types.UID("pod1")}}, expected: map[string]bool{}, }, { @@ -1118,23 +1116,6 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) { "machine2": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodNotMatchHostName}, "machine3": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeUnschedulable}, }, - pod: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "pod1", UID: types.UID("pod1")}, Spec: v1.PodSpec{Affinity: &v1.Affinity{ - PodAffinity: &v1.PodAffinity{ - RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{ - { - LabelSelector: &metav1.LabelSelector{ - MatchExpressions: []metav1.LabelSelectorRequirement{ - { - Key: "service", - Operator: metav1.LabelSelectorOpIn, - Values: []string{"securityscan", "value2"}, - }, - }, - }, - TopologyKey: "hostname", - }, - }, - }}}}, expected: map[string]bool{"machine1": true, "machine4": true}, }, { @@ -1143,40 +1124,6 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) { "machine1": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodAffinityNotMatch}, "machine2": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodNotMatchHostName}, }, - pod: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "pod1", UID: types.UID("pod1")}, Spec: v1.PodSpec{Affinity: &v1.Affinity{ - PodAffinity: &v1.PodAffinity{ - RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{ - { - LabelSelector: &metav1.LabelSelector{ - MatchExpressions: []metav1.LabelSelectorRequirement{ - { - Key: "service", - Operator: metav1.LabelSelectorOpIn, - Values: []string{"securityscan", "value2"}, - }, - }, - }, - TopologyKey: "hostname", - }, - }, - }, - PodAntiAffinity: &v1.PodAntiAffinity{ - RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{ - { - LabelSelector: &metav1.LabelSelector{ - MatchExpressions: []metav1.LabelSelectorRequirement{ - { - Key: "service", - Operator: metav1.LabelSelectorOpNotIn, - Values: []string{"blah", "foo"}, - }, - }, - }, - TopologyKey: "region", - }, - }, - }, - }}}, expected: map[string]bool{"machine1": true, "machine3": true, "machine4": true}, }, { @@ -1187,13 +1134,12 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) { "machine3": []algorithm.PredicateFailureReason{algorithmpredicates.NewInsufficientResourceError(v1.ResourceMemory, 1000, 600, 400)}, "machine4": []algorithm.PredicateFailureReason{}, }, - pod: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "pod1", UID: types.UID("pod1")}}, expected: map[string]bool{"machine3": true, "machine4": true}, }, } for _, test := range tests { - nodes := nodesWherePreemptionMightHelp(test.pod, makeNodeList(nodeNames), test.failedPredMap) + nodes := nodesWherePreemptionMightHelp(makeNodeList(nodeNames), test.failedPredMap) if len(test.expected) != len(nodes) { t.Errorf("test [%v]:number of nodes is not the same as expected. exptectd: %d, got: %d. Nodes: %v", test.name, len(test.expected), len(nodes), nodes) }