Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nomad: disable service+batch preemption by default #5778

Merged
merged 1 commit into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions command/agent/operator_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,11 @@ func TestOperator_SchedulerGetConfiguration(t *testing.T) {
require.Equal(200, resp.Code)
out, ok := obj.(structs.SchedulerConfigurationResponse)
require.True(ok)

// Only system jobs can preempt other jobs by default.
require.True(out.SchedulerConfig.PreemptionConfig.SystemSchedulerEnabled)
require.True(out.SchedulerConfig.PreemptionConfig.BatchSchedulerEnabled)
require.True(out.SchedulerConfig.PreemptionConfig.ServiceSchedulerEnabled)
require.False(out.SchedulerConfig.PreemptionConfig.BatchSchedulerEnabled)
require.False(out.SchedulerConfig.PreemptionConfig.ServiceSchedulerEnabled)
})
}

Expand Down
25 changes: 21 additions & 4 deletions internal/testing/apitests/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ func TestAPI_OperatorSchedulerGetSetConfiguration(t *testing.T) {
r.Check(err)
})
require.True(config.SchedulerConfig.PreemptionConfig.SystemSchedulerEnabled)
require.False(config.SchedulerConfig.PreemptionConfig.BatchSchedulerEnabled)
require.False(config.SchedulerConfig.PreemptionConfig.ServiceSchedulerEnabled)

// Change a config setting
newConf := &api.SchedulerConfiguration{PreemptionConfig: api.PreemptionConfig{SystemSchedulerEnabled: false, BatchSchedulerEnabled: false}}
newConf := &api.SchedulerConfiguration{
PreemptionConfig: api.PreemptionConfig{
SystemSchedulerEnabled: false,
BatchSchedulerEnabled: true,
ServiceSchedulerEnabled: true,
},
}
resp, wm, err := operator.SchedulerSetConfiguration(newConf, nil)
require.Nil(err)
require.NotZero(wm.LastIndex)
Expand All @@ -33,7 +41,8 @@ func TestAPI_OperatorSchedulerGetSetConfiguration(t *testing.T) {
config, _, err = operator.SchedulerGetConfiguration(nil)
require.Nil(err)
require.False(config.SchedulerConfig.PreemptionConfig.SystemSchedulerEnabled)
require.False(config.SchedulerConfig.PreemptionConfig.BatchSchedulerEnabled)
require.True(config.SchedulerConfig.PreemptionConfig.BatchSchedulerEnabled)
require.True(config.SchedulerConfig.PreemptionConfig.ServiceSchedulerEnabled)
}

func TestAPI_OperatorSchedulerCASConfiguration(t *testing.T) {
Expand All @@ -50,11 +59,13 @@ func TestAPI_OperatorSchedulerCASConfiguration(t *testing.T) {
r.Check(err)
})
require.True(config.SchedulerConfig.PreemptionConfig.SystemSchedulerEnabled)
require.False(config.SchedulerConfig.PreemptionConfig.BatchSchedulerEnabled)
require.False(config.SchedulerConfig.PreemptionConfig.ServiceSchedulerEnabled)

// Pass an invalid ModifyIndex
{
newConf := &api.SchedulerConfiguration{
PreemptionConfig: api.PreemptionConfig{SystemSchedulerEnabled: false, BatchSchedulerEnabled: false},
PreemptionConfig: api.PreemptionConfig{SystemSchedulerEnabled: false, BatchSchedulerEnabled: true},
ModifyIndex: config.SchedulerConfig.ModifyIndex - 1,
}
resp, wm, err := operator.SchedulerCASConfiguration(newConf, nil)
Expand All @@ -66,12 +77,18 @@ func TestAPI_OperatorSchedulerCASConfiguration(t *testing.T) {
// Pass a valid ModifyIndex
{
newConf := &api.SchedulerConfiguration{
PreemptionConfig: api.PreemptionConfig{SystemSchedulerEnabled: false, BatchSchedulerEnabled: false},
PreemptionConfig: api.PreemptionConfig{SystemSchedulerEnabled: false, BatchSchedulerEnabled: true},
ModifyIndex: config.SchedulerConfig.ModifyIndex,
}
resp, wm, err := operator.SchedulerCASConfiguration(newConf, nil)
require.Nil(err)
require.NotZero(wm.LastIndex)
require.True(resp.Updated)
}

config, _, err := operator.SchedulerGetConfiguration(nil)
require.Nil(err)
require.False(config.SchedulerConfig.PreemptionConfig.SystemSchedulerEnabled)
require.True(config.SchedulerConfig.PreemptionConfig.BatchSchedulerEnabled)
require.False(config.SchedulerConfig.PreemptionConfig.ServiceSchedulerEnabled)
}
4 changes: 2 additions & 2 deletions nomad/leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ var minSchedulerConfigVersion = version.Must(version.NewVersion("0.9.0"))
var defaultSchedulerConfig = &structs.SchedulerConfiguration{
PreemptionConfig: structs.PreemptionConfig{
SystemSchedulerEnabled: true,
BatchSchedulerEnabled: true,
ServiceSchedulerEnabled: true,
BatchSchedulerEnabled: false,
ServiceSchedulerEnabled: false,
},
}

Expand Down
20 changes: 10 additions & 10 deletions website/source/api/operator.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ $ curl \
"ModifyIndex": 5,
"PreemptionConfig": {
"SystemSchedulerEnabled": true,
"BatchSchedulerEnabled": true,
"ServiceSchedulerEnabled": true,
"BatchSchedulerEnabled": false,
"ServiceSchedulerEnabled": false
}
}
}
Expand All @@ -381,10 +381,10 @@ $ curl \
- `PreemptionConfig` `(PreemptionConfig)` - Options to enable preemption for various schedulers.
- `SystemSchedulerEnabled` `(bool: true)` - Specifies whether preemption for system jobs is enabled. Note that
this defaults to true.
- `BatchSchedulerEnabled` <sup>0.9.2</sup> `(bool: true)` (Enterprise Only) - Specifies whether preemption for batch jobs is enabled. Note that
this defaults to true.
- `ServiceSchedulerEnabled` <sup>0.9.2</sup> `(bool: true)` (Enterprise Only) - Specifies whether preemption for service jobs is enabled. Note that
this defaults to true.
- `BatchSchedulerEnabled` <sup>0.9.2</sup> `(bool: false)` (Enterprise Only) - Specifies whether preemption for batch jobs is enabled. Note that
this defaults to false and must be explicitly enabled.
- `ServiceSchedulerEnabled` <sup>0.9.2</sup> `(bool: false)` (Enterprise Only) - Specifies whether preemption for service jobs is enabled. Note that
this defaults to false and must be explicitly enabled.
- `CreateIndex` - The Raft index at which the config was created.
- `ModifyIndex` - The Raft index at which the config was modified.

Expand Down Expand Up @@ -415,17 +415,17 @@ The table below shows this endpoint's support for
```json
{
"PreemptionConfig": {
"SystemSchedulerEnabled": false,
"SystemSchedulerEnabled": true,
"BatchSchedulerEnabled": false,
"ServiceSchedulerEnabled": true,
"ServiceSchedulerEnabled": true
}
}
```

- `PreemptionConfig` `(PreemptionConfig)` - Options to enable preemption for various schedulers.
- `SystemSchedulerEnabled` `(bool: true)` - Specifies whether preemption for system jobs is enabled. Note that
if this is set to true, then system jobs can preempt any other jobs.
- `BatchSchedulerEnabled` <sup>0.9.2</sup> `(bool: true)` (Enterprise Only) - Specifies whether preemption for batch jobs is enabled. Note that
- `BatchSchedulerEnabled` <sup>0.9.2</sup> `(bool: false)` (Enterprise Only) - Specifies whether preemption for batch jobs is enabled. Note that
if this is set to true, then batch jobs can preempt any other jobs.
- `ServiceSchedulerEnabled` <sup>0.9.2</sup> `(bool: true)` (Enterprise Only) - Specifies whether preemption for service jobs is enabled. Note that
- `ServiceSchedulerEnabled` <sup>0.9.2</sup> `(bool: false)` (Enterprise Only) - Specifies whether preemption for service jobs is enabled. Note that
if this is set to true, then service jobs can preempt any other jobs.