Unverified Commit 2143fa2a authored by Preetha Appan's avatar Preetha Appan
Browse files

Use scheduler config from state store to enable/disable preemption

parent 784b96c1
Showing with 18 additions and 5 deletions
+18 -5
......@@ -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.
......
......@@ -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)
......
......@@ -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()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment