Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
2143fa2a
Unverified
Commit
2143fa2a
authored
6 years ago
by
Preetha Appan
Browse files
Options
Download
Email Patches
Plain Diff
Use scheduler config from state store to enable/disable preemption
parent
784b96c1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
scheduler/scheduler.go
+3
-0
scheduler/scheduler.go
scheduler/stack.go
+9
-5
scheduler/stack.go
scheduler/system_sched_test.go
+6
-0
scheduler/system_sched_test.go
with
18 additions
and
5 deletions
+18
-5
scheduler/scheduler.go
+
3
-
0
View file @
2143fa2a
...
...
@@ -88,6 +88,9 @@ type State interface {
// LatestDeploymentByJobID returns the latest deployment matching the given
// job ID
LatestDeploymentByJobID
(
ws
memdb
.
WatchSet
,
namespace
,
jobID
string
)
(
*
structs
.
Deployment
,
error
)
// SchedulerConfig returns config options for the scheduler
SchedulerConfig
()
(
uint64
,
*
structs
.
SchedulerConfiguration
,
error
)
}
// Planner interface is used to submit a task allocation plan.
...
...
This diff is collapsed.
Click to expand it.
scheduler/stack.go
+
9
-
5
View file @
2143fa2a
...
...
@@ -109,10 +109,9 @@ func NewGenericStack(batch bool, ctx Context) *GenericStack {
rankSource
:=
NewFeasibleRankIterator
(
ctx
,
s
.
distinctPropertyConstraint
)
// Apply the bin packing, this depends on the resources needed
// by a particular task group. Only enable eviction for the service
// scheduler as that logic is expensive.
evict
:=
!
batch
s
.
binPack
=
NewBinPackIterator
(
ctx
,
rankSource
,
evict
,
0
)
// by a particular task group.
s
.
binPack
=
NewBinPackIterator
(
ctx
,
rankSource
,
false
,
0
)
// Apply the job anti-affinity iterator. This is to avoid placing
// multiple allocations on the same node for this job.
...
...
@@ -287,7 +286,12 @@ func NewSystemStack(ctx Context) *SystemStack {
// Apply the bin packing, this depends on the resources needed
// by a particular task group. Enable eviction as system jobs are high
// priority.
s
.
binPack
=
NewBinPackIterator
(
ctx
,
rankSource
,
true
,
0
)
_
,
schedConfig
,
_
:=
s
.
ctx
.
State
()
.
SchedulerConfig
()
enablePreemption
:=
false
if
schedConfig
!=
nil
{
enablePreemption
=
schedConfig
.
EnablePreemption
}
s
.
binPack
=
NewBinPackIterator
(
ctx
,
rankSource
,
enablePreemption
,
0
)
// Apply score normalization
s
.
scoreNorm
=
NewScoreNormalizationIterator
(
ctx
,
s
.
binPack
)
...
...
This diff is collapsed.
Click to expand it.
scheduler/system_sched_test.go
+
6
-
0
View file @
2143fa2a
...
...
@@ -242,6 +242,9 @@ func TestSystemSched_ExhaustResources(t *testing.T) {
node
:=
mock
.
Node
()
noErr
(
t
,
h
.
State
.
UpsertNode
(
h
.
NextIndex
(),
node
))
// Enable Preemption
h
.
State
.
SchedulerSetConfig
(
h
.
NextIndex
(),
&
structs
.
SchedulerConfiguration
{
EnablePreemption
:
true
})
// Create a service job which consumes most of the system resources
svcJob
:=
mock
.
Job
()
svcJob
.
TaskGroups
[
0
]
.
Count
=
1
...
...
@@ -1573,6 +1576,9 @@ func TestSystemSched_Preemption(t *testing.T) {
nodes
=
append
(
nodes
,
node
)
}
// Enable Preemption
h
.
State
.
SchedulerSetConfig
(
h
.
NextIndex
(),
&
structs
.
SchedulerConfiguration
{
EnablePreemption
:
true
})
// Create some low priority batch jobs and allocations for them
// One job uses a reserved port
job1
:=
mock
.
BatchJob
()
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help