Merge pull request #5778 from hashicorp/b-preempt-off-by-default
nomad: disable service+batch preemption by default
This commit is contained in:
commit
2f90a8ddc5
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -66,7 +77,7 @@ 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)
|
||||
|
@ -74,4 +85,10 @@ func TestAPI_OperatorSchedulerCASConfiguration(t *testing.T) {
|
|||
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)
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -364,8 +364,8 @@ $ curl \
|
|||
"ModifyIndex": 5,
|
||||
"PreemptionConfig": {
|
||||
"SystemSchedulerEnabled": true,
|
||||
"BatchSchedulerEnabled": true,
|
||||
"ServiceSchedulerEnabled": true,
|
||||
"BatchSchedulerEnabled": false,
|
||||
"ServiceSchedulerEnabled": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
||||
|
@ -415,9 +415,9 @@ The table below shows this endpoint's support for
|
|||
```json
|
||||
{
|
||||
"PreemptionConfig": {
|
||||
"SystemSchedulerEnabled": false,
|
||||
"SystemSchedulerEnabled": true,
|
||||
"BatchSchedulerEnabled": false,
|
||||
"ServiceSchedulerEnabled": true,
|
||||
"ServiceSchedulerEnabled": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -425,7 +425,7 @@ The table below shows this endpoint's support for
|
|||
- `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.
|
||||
|
|
Loading…
Reference in New Issue