Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
097094e5
Commit
097094e5
authored
May 23, 2018
by
Guoliang Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused parameter (pod)
parent
86bd9771
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
57 deletions
+3
-57
generic_scheduler.go
pkg/scheduler/core/generic_scheduler.go
+2
-2
generic_scheduler_test.go
pkg/scheduler/core/generic_scheduler_test.go
+1
-55
No files found.
pkg/scheduler/core/generic_scheduler.go
View file @
097094e5
...
@@ -219,7 +219,7 @@ func (g *genericScheduler) Preempt(pod *v1.Pod, nodeLister algorithm.NodeLister,
...
@@ -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(
...
@@ -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
...
...
pkg/scheduler/core/generic_scheduler_test.go
View file @
097094e5
...
@@ -1097,7 +1097,6 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment