Commit 09b90e49 authored by Alex Dadgar's avatar Alex Dadgar
Browse files

Actually disable the schedulers

parent b6e0ceff
Showing with 10 additions and 9 deletions
+10 -9
...@@ -144,8 +144,8 @@ func convertServerConfig(agentConfig *Config, logOutput io.Writer) (*nomad.Confi ...@@ -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
......
...@@ -15,6 +15,7 @@ import ( ...@@ -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) { ...@@ -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()
......
...@@ -268,7 +268,7 @@ type ServerConfig struct { ...@@ -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 { ...@@ -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
......
...@@ -88,7 +88,7 @@ func TestConfig_Parse(t *testing.T) { ...@@ -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",
......
...@@ -105,7 +105,7 @@ func TestConfig_Merge(t *testing.T) { ...@@ -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) { ...@@ -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,
......
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