Actually disable the schedulers

This commit is contained in:
Alex Dadgar 2018-05-31 13:11:11 -07:00
parent 4134fcd2c7
commit aca8d5cece
5 changed files with 10 additions and 9 deletions

View file

@ -144,8 +144,8 @@ func convertServerConfig(agentConfig *Config, logOutput io.Writer) (*nomad.Confi
if agentConfig.Server.RaftProtocol != 0 { if agentConfig.Server.RaftProtocol != 0 {
conf.RaftConfig.ProtocolVersion = raft.ProtocolVersion(agentConfig.Server.RaftProtocol) conf.RaftConfig.ProtocolVersion = raft.ProtocolVersion(agentConfig.Server.RaftProtocol)
} }
if agentConfig.Server.NumSchedulers != 0 { if agentConfig.Server.NumSchedulers != nil {
conf.NumSchedulers = agentConfig.Server.NumSchedulers conf.NumSchedulers = *agentConfig.Server.NumSchedulers
} }
if len(agentConfig.Server.EnabledSchedulers) != 0 { if len(agentConfig.Server.EnabledSchedulers) != 0 {
// Convert to a set and require the core scheduler // Convert to a set and require the core scheduler

View file

@ -15,6 +15,7 @@ import (
"github.com/golang/snappy" "github.com/golang/snappy"
"github.com/hashicorp/nomad/acl" "github.com/hashicorp/nomad/acl"
"github.com/hashicorp/nomad/client/allocdir" "github.com/hashicorp/nomad/client/allocdir"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/helper/uuid" "github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/mock" "github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/nomad/structs"
@ -437,7 +438,7 @@ func TestHTTP_AllocSnapshot_Atomic(t *testing.T) {
t.Parallel() t.Parallel()
httpTest(t, func(c *Config) { httpTest(t, func(c *Config) {
// Disable the schedulers // Disable the schedulers
c.Server.NumSchedulers = 0 c.Server.NumSchedulers = helper.IntToPtr(0)
}, func(s *TestAgent) { }, func(s *TestAgent) {
// Create an alloc // Create an alloc
state := s.server.State() state := s.server.State()

View file

@ -268,7 +268,7 @@ type ServerConfig struct {
// NumSchedulers is the number of scheduler thread that are run. // NumSchedulers is the number of scheduler thread that are run.
// This can be as many as one per core, or zero to disable this server // This can be as many as one per core, or zero to disable this server
// from doing any scheduling work. // from doing any scheduling work.
NumSchedulers int `mapstructure:"num_schedulers"` NumSchedulers *int `mapstructure:"num_schedulers"`
// EnabledSchedulers controls the set of sub-schedulers that are // EnabledSchedulers controls the set of sub-schedulers that are
// enabled for this server to handle. This will restrict the evaluations // enabled for this server to handle. This will restrict the evaluations
@ -1009,8 +1009,8 @@ func (a *ServerConfig) Merge(b *ServerConfig) *ServerConfig {
if b.RaftProtocol != 0 { if b.RaftProtocol != 0 {
result.RaftProtocol = b.RaftProtocol result.RaftProtocol = b.RaftProtocol
} }
if b.NumSchedulers != 0 { if b.NumSchedulers != nil {
result.NumSchedulers = b.NumSchedulers result.NumSchedulers = helper.IntToPtr(*b.NumSchedulers)
} }
if b.NodeGCThreshold != "" { if b.NodeGCThreshold != "" {
result.NodeGCThreshold = b.NodeGCThreshold result.NodeGCThreshold = b.NodeGCThreshold

View file

@ -88,7 +88,7 @@ func TestConfig_Parse(t *testing.T) {
DataDir: "/tmp/data", DataDir: "/tmp/data",
ProtocolVersion: 3, ProtocolVersion: 3,
RaftProtocol: 3, RaftProtocol: 3,
NumSchedulers: 2, NumSchedulers: helper.IntToPtr(2),
EnabledSchedulers: []string{"test"}, EnabledSchedulers: []string{"test"},
NodeGCThreshold: "12h", NodeGCThreshold: "12h",
EvalGCThreshold: "12h", EvalGCThreshold: "12h",

View file

@ -105,7 +105,7 @@ func TestConfig_Merge(t *testing.T) {
DataDir: "/tmp/data1", DataDir: "/tmp/data1",
ProtocolVersion: 1, ProtocolVersion: 1,
RaftProtocol: 1, RaftProtocol: 1,
NumSchedulers: 1, NumSchedulers: helper.IntToPtr(1),
NodeGCThreshold: "1h", NodeGCThreshold: "1h",
HeartbeatGrace: 30 * time.Second, HeartbeatGrace: 30 * time.Second,
MinHeartbeatTTL: 30 * time.Second, MinHeartbeatTTL: 30 * time.Second,
@ -255,7 +255,7 @@ func TestConfig_Merge(t *testing.T) {
DataDir: "/tmp/data2", DataDir: "/tmp/data2",
ProtocolVersion: 2, ProtocolVersion: 2,
RaftProtocol: 2, RaftProtocol: 2,
NumSchedulers: 2, NumSchedulers: helper.IntToPtr(2),
EnabledSchedulers: []string{structs.JobTypeBatch}, EnabledSchedulers: []string{structs.JobTypeBatch},
NodeGCThreshold: "12h", NodeGCThreshold: "12h",
HeartbeatGrace: 2 * time.Minute, HeartbeatGrace: 2 * time.Minute,