nomad: disable service+batch preemption by default

Enterprise only.

Disable preemption for service and batch jobs by default.

Maintain backward compatibility in a x.y.Z release. Consider switching
the default for new clusters in the future.
This commit is contained in:
Michael Schurter
2019-06-04 15:41:40 -07:00
parent 50fc86ad26
commit 1186d77133
4 changed files with 37 additions and 18 deletions

View File

@@ -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)
}