mirror of
https://github.com/kemko/nomad.git
synced 2026-01-09 20:05:42 +03:00
Merge pull request #5269 from hashicorp/b_schedconfig_panicfix
Guard operator endpoints for minimum server version
This commit is contained in:
@@ -236,6 +236,11 @@ func (op *Operator) AutopilotSetConfiguration(args *structs.AutopilotSetConfigRe
|
||||
return structs.ErrPermissionDenied
|
||||
}
|
||||
|
||||
// All servers should be at or above 0.8.0 to apply this operatation
|
||||
if !ServersMeetMinimumVersion(op.srv.Members(), minAutopilotVersion) {
|
||||
return fmt.Errorf("All servers should be running version %v to update autopilot config", minAutopilotVersion)
|
||||
}
|
||||
|
||||
// Apply the update
|
||||
resp, _, err := op.srv.raftApply(structs.AutopilotRequestType, args)
|
||||
if err != nil {
|
||||
@@ -299,6 +304,10 @@ func (op *Operator) SchedulerSetConfiguration(args *structs.SchedulerSetConfigRe
|
||||
return structs.ErrPermissionDenied
|
||||
}
|
||||
|
||||
// All servers should be at or above 0.9.0 to apply this operatation
|
||||
if !ServersMeetMinimumVersion(op.srv.Members(), minSchedulerConfigVersion) {
|
||||
return fmt.Errorf("All servers should be running version %v to update scheduler config", minSchedulerConfigVersion)
|
||||
}
|
||||
// Apply the update
|
||||
resp, index, err := op.srv.raftApply(structs.SchedulerConfigRequestType, args)
|
||||
if err != nil {
|
||||
|
||||
@@ -337,7 +337,9 @@ func TestOperator_RaftRemovePeerByID_ACL(t *testing.T) {
|
||||
|
||||
func TestOperator_SchedulerGetConfiguration(t *testing.T) {
|
||||
t.Parallel()
|
||||
s1 := TestServer(t, nil)
|
||||
s1 := TestServer(t, func(c *Config) {
|
||||
c.Build = "0.9.0+unittest"
|
||||
})
|
||||
defer s1.Shutdown()
|
||||
codec := rpcClient(t, s1)
|
||||
testutil.WaitForLeader(t, s1.RPC)
|
||||
@@ -358,7 +360,9 @@ func TestOperator_SchedulerGetConfiguration(t *testing.T) {
|
||||
|
||||
func TestOperator_SchedulerSetConfiguration(t *testing.T) {
|
||||
t.Parallel()
|
||||
s1 := TestServer(t, nil)
|
||||
s1 := TestServer(t, func(c *Config) {
|
||||
c.Build = "0.9.0+unittest"
|
||||
})
|
||||
defer s1.Shutdown()
|
||||
codec := rpcClient(t, s1)
|
||||
testutil.WaitForLeader(t, s1.RPC)
|
||||
@@ -399,6 +403,7 @@ func TestOperator_SchedulerGetConfiguration_ACL(t *testing.T) {
|
||||
t.Parallel()
|
||||
s1, root := TestACLServer(t, func(c *Config) {
|
||||
c.RaftConfig.ProtocolVersion = 3
|
||||
c.Build = "0.9.0+unittest"
|
||||
})
|
||||
defer s1.Shutdown()
|
||||
codec := rpcClient(t, s1)
|
||||
@@ -444,6 +449,7 @@ func TestOperator_SchedulerSetConfiguration_ACL(t *testing.T) {
|
||||
t.Parallel()
|
||||
s1, root := TestACLServer(t, func(c *Config) {
|
||||
c.RaftConfig.ProtocolVersion = 3
|
||||
c.Build = "0.9.0+unittest"
|
||||
})
|
||||
defer s1.Shutdown()
|
||||
codec := rpcClient(t, s1)
|
||||
|
||||
Reference in New Issue
Block a user