diff --git a/api/jobs.go b/api/jobs.go index c9921c9fd3b..0e0fc34cd3a 100644 --- a/api/jobs.go +++ b/api/jobs.go @@ -25,6 +25,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" @@ -938,7 +941,7 @@ func (j *Job) Canonicalize() { j.Namespace = pointerOf(DefaultNamespace) } if j.Priority == nil { - j.Priority = pointerOf(50) + 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 80631725328..f7f095224d1 100644 --- a/api/jobs_test.go +++ b/api/jobs_test.go @@ -6,9 +6,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) { @@ -279,7 +280,7 @@ func TestJobs_Canonicalize(t *testing.T) { Namespace: pointerOf(DefaultNamespace), Type: pointerOf("service"), ParentID: pointerOf(""), - Priority: pointerOf(50), + Priority: pointerOf(JobDefaultPriority), AllAtOnce: pointerOf(false), ConsulToken: pointerOf(""), ConsulNamespace: pointerOf(""), @@ -374,7 +375,7 @@ func TestJobs_Canonicalize(t *testing.T) { Namespace: pointerOf(DefaultNamespace), Type: pointerOf("batch"), ParentID: pointerOf(""), - Priority: pointerOf(50), + Priority: pointerOf(JobDefaultPriority), AllAtOnce: pointerOf(false), ConsulToken: pointerOf(""), ConsulNamespace: pointerOf(""), @@ -452,7 +453,7 @@ func TestJobs_Canonicalize(t *testing.T) { Region: pointerOf("global"), Type: pointerOf("service"), ParentID: pointerOf("lol"), - Priority: pointerOf(50), + Priority: pointerOf(JobDefaultPriority), AllAtOnce: pointerOf(false), ConsulToken: pointerOf(""), ConsulNamespace: pointerOf(""), @@ -621,7 +622,7 @@ func TestJobs_Canonicalize(t *testing.T) { ID: pointerOf("example_template"), Name: pointerOf("example_template"), ParentID: pointerOf(""), - Priority: pointerOf(50), + Priority: pointerOf(JobDefaultPriority), Region: pointerOf("global"), Type: pointerOf("service"), AllAtOnce: pointerOf(false), @@ -791,7 +792,7 @@ func TestJobs_Canonicalize(t *testing.T) { Name: pointerOf("bar"), Region: pointerOf("global"), Type: pointerOf("service"), - Priority: pointerOf(50), + Priority: pointerOf(JobDefaultPriority), AllAtOnce: pointerOf(false), ConsulToken: pointerOf(""), ConsulNamespace: pointerOf(""), @@ -882,7 +883,7 @@ func TestJobs_Canonicalize(t *testing.T) { Region: pointerOf("global"), Type: pointerOf("service"), ParentID: pointerOf("lol"), - Priority: pointerOf(50), + Priority: pointerOf(JobDefaultPriority), AllAtOnce: pointerOf(false), ConsulToken: pointerOf(""), ConsulNamespace: pointerOf(""), @@ -1058,7 +1059,7 @@ func TestJobs_Canonicalize(t *testing.T) { Region: pointerOf("global"), Type: pointerOf("service"), ParentID: pointerOf("lol"), - Priority: pointerOf(50), + Priority: pointerOf(JobDefaultPriority), AllAtOnce: pointerOf(false), ConsulToken: pointerOf(""), ConsulNamespace: pointerOf(""), @@ -1229,7 +1230,7 @@ func TestJobs_Canonicalize(t *testing.T) { Region: pointerOf("global"), Type: pointerOf("service"), ParentID: pointerOf("lol"), - Priority: pointerOf(50), + Priority: pointerOf(JobDefaultPriority), AllAtOnce: pointerOf(false), ConsulToken: pointerOf(""), ConsulNamespace: pointerOf(""),