fix: job canonicalization should set job priority to 50, not 0. (#17314)
Nomad API will reject jobs with priority set to 0.
This commit is contained in:
parent
294aa4bfe7
commit
cea48b24ee
|
@ -29,6 +29,9 @@ const (
|
||||||
// on all clients.
|
// on all clients.
|
||||||
JobTypeSysbatch = "sysbatch"
|
JobTypeSysbatch = "sysbatch"
|
||||||
|
|
||||||
|
// JobDefaultPriority is the default priority if not specified.
|
||||||
|
JobDefaultPriority = 50
|
||||||
|
|
||||||
// PeriodicSpecCron is used for a cron spec.
|
// PeriodicSpecCron is used for a cron spec.
|
||||||
PeriodicSpecCron = "cron"
|
PeriodicSpecCron = "cron"
|
||||||
|
|
||||||
|
@ -1003,7 +1006,7 @@ func (j *Job) Canonicalize() {
|
||||||
j.Namespace = pointerOf(DefaultNamespace)
|
j.Namespace = pointerOf(DefaultNamespace)
|
||||||
}
|
}
|
||||||
if j.Priority == nil {
|
if j.Priority == nil {
|
||||||
j.Priority = pointerOf(0)
|
j.Priority = pointerOf(JobDefaultPriority)
|
||||||
}
|
}
|
||||||
if j.Stop == nil {
|
if j.Stop == nil {
|
||||||
j.Stop = pointerOf(false)
|
j.Stop = pointerOf(false)
|
||||||
|
|
|
@ -9,9 +9,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/nomad/api/internal/testutil"
|
|
||||||
"github.com/shoenig/test/must"
|
"github.com/shoenig/test/must"
|
||||||
"github.com/shoenig/test/wait"
|
"github.com/shoenig/test/wait"
|
||||||
|
|
||||||
|
"github.com/hashicorp/nomad/api/internal/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestJobs_Register(t *testing.T) {
|
func TestJobs_Register(t *testing.T) {
|
||||||
|
@ -282,7 +283,7 @@ func TestJobs_Canonicalize(t *testing.T) {
|
||||||
Namespace: pointerOf(DefaultNamespace),
|
Namespace: pointerOf(DefaultNamespace),
|
||||||
Type: pointerOf("service"),
|
Type: pointerOf("service"),
|
||||||
ParentID: pointerOf(""),
|
ParentID: pointerOf(""),
|
||||||
Priority: pointerOf(0),
|
Priority: pointerOf(JobDefaultPriority),
|
||||||
AllAtOnce: pointerOf(false),
|
AllAtOnce: pointerOf(false),
|
||||||
ConsulToken: pointerOf(""),
|
ConsulToken: pointerOf(""),
|
||||||
ConsulNamespace: pointerOf(""),
|
ConsulNamespace: pointerOf(""),
|
||||||
|
@ -377,7 +378,7 @@ func TestJobs_Canonicalize(t *testing.T) {
|
||||||
Namespace: pointerOf(DefaultNamespace),
|
Namespace: pointerOf(DefaultNamespace),
|
||||||
Type: pointerOf("batch"),
|
Type: pointerOf("batch"),
|
||||||
ParentID: pointerOf(""),
|
ParentID: pointerOf(""),
|
||||||
Priority: pointerOf(0),
|
Priority: pointerOf(JobDefaultPriority),
|
||||||
AllAtOnce: pointerOf(false),
|
AllAtOnce: pointerOf(false),
|
||||||
ConsulToken: pointerOf(""),
|
ConsulToken: pointerOf(""),
|
||||||
ConsulNamespace: pointerOf(""),
|
ConsulNamespace: pointerOf(""),
|
||||||
|
@ -455,7 +456,7 @@ func TestJobs_Canonicalize(t *testing.T) {
|
||||||
Region: pointerOf("global"),
|
Region: pointerOf("global"),
|
||||||
Type: pointerOf("service"),
|
Type: pointerOf("service"),
|
||||||
ParentID: pointerOf("lol"),
|
ParentID: pointerOf("lol"),
|
||||||
Priority: pointerOf(0),
|
Priority: pointerOf(JobDefaultPriority),
|
||||||
AllAtOnce: pointerOf(false),
|
AllAtOnce: pointerOf(false),
|
||||||
ConsulToken: pointerOf(""),
|
ConsulToken: pointerOf(""),
|
||||||
ConsulNamespace: pointerOf(""),
|
ConsulNamespace: pointerOf(""),
|
||||||
|
@ -624,7 +625,7 @@ func TestJobs_Canonicalize(t *testing.T) {
|
||||||
ID: pointerOf("example_template"),
|
ID: pointerOf("example_template"),
|
||||||
Name: pointerOf("example_template"),
|
Name: pointerOf("example_template"),
|
||||||
ParentID: pointerOf(""),
|
ParentID: pointerOf(""),
|
||||||
Priority: pointerOf(0),
|
Priority: pointerOf(JobDefaultPriority),
|
||||||
Region: pointerOf("global"),
|
Region: pointerOf("global"),
|
||||||
Type: pointerOf("service"),
|
Type: pointerOf("service"),
|
||||||
AllAtOnce: pointerOf(false),
|
AllAtOnce: pointerOf(false),
|
||||||
|
@ -794,7 +795,7 @@ func TestJobs_Canonicalize(t *testing.T) {
|
||||||
Name: pointerOf("bar"),
|
Name: pointerOf("bar"),
|
||||||
Region: pointerOf("global"),
|
Region: pointerOf("global"),
|
||||||
Type: pointerOf("service"),
|
Type: pointerOf("service"),
|
||||||
Priority: pointerOf(0),
|
Priority: pointerOf(JobDefaultPriority),
|
||||||
AllAtOnce: pointerOf(false),
|
AllAtOnce: pointerOf(false),
|
||||||
ConsulToken: pointerOf(""),
|
ConsulToken: pointerOf(""),
|
||||||
ConsulNamespace: pointerOf(""),
|
ConsulNamespace: pointerOf(""),
|
||||||
|
@ -885,7 +886,7 @@ func TestJobs_Canonicalize(t *testing.T) {
|
||||||
Region: pointerOf("global"),
|
Region: pointerOf("global"),
|
||||||
Type: pointerOf("service"),
|
Type: pointerOf("service"),
|
||||||
ParentID: pointerOf("lol"),
|
ParentID: pointerOf("lol"),
|
||||||
Priority: pointerOf(0),
|
Priority: pointerOf(JobDefaultPriority),
|
||||||
AllAtOnce: pointerOf(false),
|
AllAtOnce: pointerOf(false),
|
||||||
ConsulToken: pointerOf(""),
|
ConsulToken: pointerOf(""),
|
||||||
ConsulNamespace: pointerOf(""),
|
ConsulNamespace: pointerOf(""),
|
||||||
|
@ -1061,7 +1062,7 @@ func TestJobs_Canonicalize(t *testing.T) {
|
||||||
Region: pointerOf("global"),
|
Region: pointerOf("global"),
|
||||||
Type: pointerOf("service"),
|
Type: pointerOf("service"),
|
||||||
ParentID: pointerOf("lol"),
|
ParentID: pointerOf("lol"),
|
||||||
Priority: pointerOf(0),
|
Priority: pointerOf(JobDefaultPriority),
|
||||||
AllAtOnce: pointerOf(false),
|
AllAtOnce: pointerOf(false),
|
||||||
ConsulToken: pointerOf(""),
|
ConsulToken: pointerOf(""),
|
||||||
ConsulNamespace: pointerOf(""),
|
ConsulNamespace: pointerOf(""),
|
||||||
|
@ -1232,7 +1233,7 @@ func TestJobs_Canonicalize(t *testing.T) {
|
||||||
Region: pointerOf("global"),
|
Region: pointerOf("global"),
|
||||||
Type: pointerOf("service"),
|
Type: pointerOf("service"),
|
||||||
ParentID: pointerOf("lol"),
|
ParentID: pointerOf("lol"),
|
||||||
Priority: pointerOf(0),
|
Priority: pointerOf(JobDefaultPriority),
|
||||||
AllAtOnce: pointerOf(false),
|
AllAtOnce: pointerOf(false),
|
||||||
ConsulToken: pointerOf(""),
|
ConsulToken: pointerOf(""),
|
||||||
ConsulNamespace: pointerOf(""),
|
ConsulNamespace: pointerOf(""),
|
||||||
|
|
Loading…
Reference in New Issue