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
14824835
Unverified
Commit
14824835
authored
Jan 14, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Jan 14, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #72895 from bsalamat/no_refresh_preemption
Do not snapshot scheduler cache before starting preemption
parents
d3540b90
12732129
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
generic_scheduler.go
pkg/scheduler/core/generic_scheduler.go
+9
-6
generic_scheduler_test.go
pkg/scheduler/core/generic_scheduler_test.go
+6
-1
No files found.
pkg/scheduler/core/generic_scheduler.go
View file @
14824835
...
@@ -275,6 +275,13 @@ func (g *genericScheduler) selectHost(priorityList schedulerapi.HostPriorityList
...
@@ -275,6 +275,13 @@ func (g *genericScheduler) selectHost(priorityList schedulerapi.HostPriorityList
// returns 1) the node, 2) the list of preempted pods if such a node is found,
// returns 1) the node, 2) the list of preempted pods if such a node is found,
// 3) A list of pods whose nominated node name should be cleared, and 4) any
// 3) A list of pods whose nominated node name should be cleared, and 4) any
// possible error.
// possible error.
// Preempt does not update its snapshot. It uses the same snapshot used in the
// scheduling cycle. This is to avoid a scenario where preempt finds feasible
// nodes without preempting any pod. When there are many pending pods in the
// scheduling queue a nominated pod will go back to the queue and behind
// other pods with the same priority. The nominated pod prevents other pods from
// using the nominated resources and the nominated pod could take a long time
// before it is retried after many other pending pods.
func
(
g
*
genericScheduler
)
Preempt
(
pod
*
v1
.
Pod
,
nodeLister
algorithm
.
NodeLister
,
scheduleErr
error
)
(
*
v1
.
Node
,
[]
*
v1
.
Pod
,
[]
*
v1
.
Pod
,
error
)
{
func
(
g
*
genericScheduler
)
Preempt
(
pod
*
v1
.
Pod
,
nodeLister
algorithm
.
NodeLister
,
scheduleErr
error
)
(
*
v1
.
Node
,
[]
*
v1
.
Pod
,
[]
*
v1
.
Pod
,
error
)
{
// Scheduler may return various types of errors. Consider preemption only if
// Scheduler may return various types of errors. Consider preemption only if
// the error is of type FitError.
// the error is of type FitError.
...
@@ -282,10 +289,6 @@ func (g *genericScheduler) Preempt(pod *v1.Pod, nodeLister algorithm.NodeLister,
...
@@ -282,10 +289,6 @@ func (g *genericScheduler) Preempt(pod *v1.Pod, nodeLister algorithm.NodeLister,
if
!
ok
||
fitError
==
nil
{
if
!
ok
||
fitError
==
nil
{
return
nil
,
nil
,
nil
,
nil
return
nil
,
nil
,
nil
,
nil
}
}
err
:=
g
.
snapshot
()
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
if
!
podEligibleToPreemptOthers
(
pod
,
g
.
cachedNodeInfoMap
)
{
if
!
podEligibleToPreemptOthers
(
pod
,
g
.
cachedNodeInfoMap
)
{
klog
.
V
(
5
)
.
Infof
(
"Pod %v/%v is not eligible for more preemption."
,
pod
.
Namespace
,
pod
.
Name
)
klog
.
V
(
5
)
.
Infof
(
"Pod %v/%v is not eligible for more preemption."
,
pod
.
Namespace
,
pod
.
Name
)
return
nil
,
nil
,
nil
,
nil
return
nil
,
nil
,
nil
,
nil
...
@@ -1076,7 +1079,7 @@ func nodesWherePreemptionMightHelp(nodes []*v1.Node, failedPredicatesMap FailedP
...
@@ -1076,7 +1079,7 @@ func nodesWherePreemptionMightHelp(nodes []*v1.Node, failedPredicatesMap FailedP
potentialNodes
:=
[]
*
v1
.
Node
{}
potentialNodes
:=
[]
*
v1
.
Node
{}
for
_
,
node
:=
range
nodes
{
for
_
,
node
:=
range
nodes
{
unresolvableReasonExist
:=
false
unresolvableReasonExist
:=
false
failedPredicates
,
found
:=
failedPredicatesMap
[
node
.
Name
]
failedPredicates
,
_
:=
failedPredicatesMap
[
node
.
Name
]
// If we assume that scheduler looks at all nodes and populates the failedPredicateMap
// If we assume that scheduler looks at all nodes and populates the failedPredicateMap
// (which is the case today), the !found case should never happen, but we'd prefer
// (which is the case today), the !found case should never happen, but we'd prefer
// to rely less on such assumptions in the code when checking does not impose
// to rely less on such assumptions in the code when checking does not impose
...
@@ -1107,7 +1110,7 @@ func nodesWherePreemptionMightHelp(nodes []*v1.Node, failedPredicatesMap FailedP
...
@@ -1107,7 +1110,7 @@ func nodesWherePreemptionMightHelp(nodes []*v1.Node, failedPredicatesMap FailedP
break
break
}
}
}
}
if
!
found
||
!
unresolvableReasonExist
{
if
!
unresolvableReasonExist
{
klog
.
V
(
3
)
.
Infof
(
"Node %v is a potential node for preemption."
,
node
.
Name
)
klog
.
V
(
3
)
.
Infof
(
"Node %v is a potential node for preemption."
,
node
.
Name
)
potentialNodes
=
append
(
potentialNodes
,
node
)
potentialNodes
=
append
(
potentialNodes
,
node
)
}
}
...
...
pkg/scheduler/core/generic_scheduler_test.go
View file @
14824835
...
@@ -1407,6 +1407,7 @@ func TestPreempt(t *testing.T) {
...
@@ -1407,6 +1407,7 @@ func TestPreempt(t *testing.T) {
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Logf
(
"===== Running test %v"
,
t
.
Name
())
stop
:=
make
(
chan
struct
{})
stop
:=
make
(
chan
struct
{})
cache
:=
schedulerinternalcache
.
New
(
time
.
Duration
(
0
),
stop
)
cache
:=
schedulerinternalcache
.
New
(
time
.
Duration
(
0
),
stop
)
for
_
,
pod
:=
range
test
.
pods
{
for
_
,
pod
:=
range
test
.
pods
{
...
@@ -1443,14 +1444,18 @@ func TestPreempt(t *testing.T) {
...
@@ -1443,14 +1444,18 @@ func TestPreempt(t *testing.T) {
false
,
false
,
false
,
false
,
schedulerapi
.
DefaultPercentageOfNodesToScore
)
schedulerapi
.
DefaultPercentageOfNodesToScore
)
scheduler
.
(
*
genericScheduler
)
.
snapshot
()
// Call Preempt and check the expected results.
// Call Preempt and check the expected results.
node
,
victims
,
_
,
err
:=
scheduler
.
Preempt
(
test
.
pod
,
schedulertesting
.
FakeNodeLister
(
makeNodeList
(
nodeNames
)),
error
(
&
FitError
{
Pod
:
test
.
pod
,
FailedPredicates
:
failedPredMap
}))
node
,
victims
,
_
,
err
:=
scheduler
.
Preempt
(
test
.
pod
,
schedulertesting
.
FakeNodeLister
(
makeNodeList
(
nodeNames
)),
error
(
&
FitError
{
Pod
:
test
.
pod
,
FailedPredicates
:
failedPredMap
}))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error in preemption: %v"
,
err
)
t
.
Errorf
(
"unexpected error in preemption: %v"
,
err
)
}
}
if
(
node
!=
nil
&&
node
.
Name
!=
test
.
expectedNode
)
||
(
node
==
nil
&&
len
(
test
.
expectedNode
)
!=
0
)
{
if
node
!=
nil
&&
node
.
Name
!=
test
.
expectedNode
{
t
.
Errorf
(
"expected node: %v, got: %v"
,
test
.
expectedNode
,
node
.
GetName
())
t
.
Errorf
(
"expected node: %v, got: %v"
,
test
.
expectedNode
,
node
.
GetName
())
}
}
if
node
==
nil
&&
len
(
test
.
expectedNode
)
!=
0
{
t
.
Errorf
(
"expected node: %v, got: nothing"
,
test
.
expectedNode
)
}
if
len
(
victims
)
!=
len
(
test
.
expectedPods
)
{
if
len
(
victims
)
!=
len
(
test
.
expectedPods
)
{
t
.
Errorf
(
"expected %v pods, got %v."
,
len
(
test
.
expectedPods
),
len
(
victims
))
t
.
Errorf
(
"expected %v pods, got %v."
,
len
(
test
.
expectedPods
),
len
(
victims
))
}
}
...
...
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