Remove unused parameter (pod)

pull/8/head
Guoliang Wang 2018-05-23 13:56:17 +08:00
parent 86bd977151
commit 097094e5fa
2 changed files with 3 additions and 57 deletions

View File

@ -219,7 +219,7 @@ func (g *genericScheduler) Preempt(pod *v1.Pod, nodeLister algorithm.NodeLister,
if len(allNodes) == 0 { if len(allNodes) == 0 {
return nil, nil, nil, ErrNoNodesAvailable return nil, nil, nil, ErrNoNodesAvailable
} }
potentialNodes := nodesWherePreemptionMightHelp(pod, allNodes, fitError.FailedPredicates) potentialNodes := nodesWherePreemptionMightHelp(allNodes, fitError.FailedPredicates)
if len(potentialNodes) == 0 { if len(potentialNodes) == 0 {
glog.V(3).Infof("Preemption will not help schedule pod %v on any node.", pod.Name) 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. // 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 // nodesWherePreemptionMightHelp returns a list of nodes with failed predicates
// that may be satisfied by removing pods from the node. // 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{} potentialNodes := []*v1.Node{}
for _, node := range nodes { for _, node := range nodes {
unresolvableReasonExist := false unresolvableReasonExist := false

View File

@ -1097,7 +1097,6 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
failedPredMap FailedPredicateMap failedPredMap FailedPredicateMap
pod *v1.Pod
expected map[string]bool // set of expected node names. Value is ignored. 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}, "machine3": []algorithm.PredicateFailureReason{algorithmpredicates.ErrTaintsTolerationsNotMatch},
"machine4": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeLabelPresenceViolated}, "machine4": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeLabelPresenceViolated},
}, },
pod: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "pod1", UID: types.UID("pod1")}},
expected: map[string]bool{}, expected: map[string]bool{},
}, },
{ {
@ -1118,23 +1116,6 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) {
"machine2": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodNotMatchHostName}, "machine2": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodNotMatchHostName},
"machine3": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeUnschedulable}, "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}, expected: map[string]bool{"machine1": true, "machine4": true},
}, },
{ {
@ -1143,40 +1124,6 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) {
"machine1": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodAffinityNotMatch}, "machine1": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodAffinityNotMatch},
"machine2": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodNotMatchHostName}, "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}, 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)}, "machine3": []algorithm.PredicateFailureReason{algorithmpredicates.NewInsufficientResourceError(v1.ResourceMemory, 1000, 600, 400)},
"machine4": []algorithm.PredicateFailureReason{}, "machine4": []algorithm.PredicateFailureReason{},
}, },
pod: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "pod1", UID: types.UID("pod1")}},
expected: map[string]bool{"machine3": true, "machine4": true}, expected: map[string]bool{"machine3": true, "machine4": true},
}, },
} }
for _, test := range tests { for _, test := range tests {
nodes := nodesWherePreemptionMightHelp(test.pod, makeNodeList(nodeNames), test.failedPredMap) nodes := nodesWherePreemptionMightHelp(makeNodeList(nodeNames), test.failedPredMap)
if len(test.expected) != len(nodes) { 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) 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)
} }