diff --git a/api/jobs.go b/api/jobs.go index 64b25c710..d05b87891 100644 --- a/api/jobs.go +++ b/api/jobs.go @@ -29,6 +29,9 @@ const ( // on all clients. JobTypeSysbatch = "sysbatch" + // JobDefaultPriority is the default priority if not specified. + JobDefaultPriority = 50 + // PeriodicSpecCron is used for a cron spec. PeriodicSpecCron = "cron" @@ -1003,7 +1006,7 @@ func (j *Job) Canonicalize() { j.Namespace = pointerOf(DefaultNamespace) } if j.Priority == nil { - j.Priority = pointerOf(0) + j.Priority = pointerOf(JobDefaultPriority) } if j.Stop == nil { j.Stop = pointerOf(false) diff --git a/api/jobs_test.go b/api/jobs_test.go index 60d158542..dc642bab3 100644 --- a/api/jobs_test.go +++ b/api/jobs_test.go @@ -9,9 +9,10 @@ import ( "testing" "time" - "github.com/hashicorp/nomad/api/internal/testutil" "github.com/shoenig/test/must" "github.com/shoenig/test/wait" + + "github.com/hashicorp/nomad/api/internal/testutil" ) func TestJobs_Register(t *testing.T) { @@ -282,7 +283,7 @@ func TestJobs_Canonicalize(t *testing.T) { Namespace: pointerOf(DefaultNamespace), Type: pointerOf("service"), ParentID: pointerOf(""), - Priority: pointerOf(0), + Priority: pointerOf(JobDefaultPriority), AllAtOnce: pointerOf(false), ConsulToken: pointerOf(""), ConsulNamespace: pointerOf(""), @@ -377,7 +378,7 @@ func TestJobs_Canonicalize(t *testing.T) { Namespace: pointerOf(DefaultNamespace), Type: pointerOf("batch"), ParentID: pointerOf(""), - Priority: pointerOf(0), + Priority: pointerOf(JobDefaultPriority), AllAtOnce: pointerOf(false), ConsulToken: pointerOf(""), ConsulNamespace: pointerOf(""), @@ -455,7 +456,7 @@ func TestJobs_Canonicalize(t *testing.T) { Region: pointerOf("global"), Type: pointerOf("service"), ParentID: pointerOf("lol"), - Priority: pointerOf(0), + Priority: pointerOf(JobDefaultPriority), AllAtOnce: pointerOf(false), ConsulToken: pointerOf(""), ConsulNamespace: pointerOf(""), @@ -624,7 +625,7 @@ func TestJobs_Canonicalize(t *testing.T) { ID: pointerOf("example_template"), Name: pointerOf("example_template"), ParentID: pointerOf(""), - Priority: pointerOf(0), + Priority: pointerOf(JobDefaultPriority), Region: pointerOf("global"), Type: pointerOf("service"), AllAtOnce: pointerOf(false), @@ -794,7 +795,7 @@ func TestJobs_Canonicalize(t *testing.T) { Name: pointerOf("bar"), Region: pointerOf("global"), Type: pointerOf("service"), - Priority: pointerOf(0), + Priority: pointerOf(JobDefaultPriority), AllAtOnce: pointerOf(false), ConsulToken: pointerOf(""), ConsulNamespace: pointerOf(""), @@ -885,7 +886,7 @@ func TestJobs_Canonicalize(t *testing.T) { Region: pointerOf("global"), Type: pointerOf("service"), ParentID: pointerOf("lol"), - Priority: pointerOf(0), + Priority: pointerOf(JobDefaultPriority), AllAtOnce: pointerOf(false), ConsulToken: pointerOf(""), ConsulNamespace: pointerOf(""), @@ -1061,7 +1062,7 @@ func TestJobs_Canonicalize(t *testing.T) { Region: pointerOf("global"), Type: pointerOf("service"), ParentID: pointerOf("lol"), - Priority: pointerOf(0), + Priority: pointerOf(JobDefaultPriority), AllAtOnce: pointerOf(false), ConsulToken: pointerOf(""), ConsulNamespace: pointerOf(""), @@ -1232,7 +1233,7 @@ func TestJobs_Canonicalize(t *testing.T) { Region: pointerOf("global"), Type: pointerOf("service"), ParentID: pointerOf("lol"), - Priority: pointerOf(0), + Priority: pointerOf(JobDefaultPriority), AllAtOnce: pointerOf(false), ConsulToken: pointerOf(""), ConsulNamespace: pointerOf(""),