diff --git a/nomad/job_endpoint.go b/nomad/job_endpoint.go index 9948b5a66..d1e2af642 100644 --- a/nomad/job_endpoint.go +++ b/nomad/job_endpoint.go @@ -1325,6 +1325,7 @@ func validateJob(job *structs.Job) (invalid, warnings error) { // validateJobUpdate ensures updates to a job are valid. func validateJobUpdate(old, new *structs.Job) error { + // Validate Dispatch not set on new Jobs if old == nil { if new.Dispatched { return fmt.Errorf("job can't be submitted with 'Dispatched' set") @@ -1407,7 +1408,6 @@ func (j *Job) Dispatch(args *structs.JobDispatchRequest, reply *structs.JobDispa // Derive the child job and commit it via Raft dispatchJob := parameterizedJob.Copy() - dispatchJob.ParameterizedJob = nil dispatchJob.ID = structs.DispatchedID(parameterizedJob.ID, time.Now()) dispatchJob.ParentID = parameterizedJob.ID dispatchJob.Name = dispatchJob.ID diff --git a/nomad/job_endpoint_test.go b/nomad/job_endpoint_test.go index 3aab1a14b..a1d389bdc 100644 --- a/nomad/job_endpoint_test.go +++ b/nomad/job_endpoint_test.go @@ -4384,6 +4384,12 @@ func TestJobEndpoint_Dispatch(t *testing.T) { if !out.Dispatched { t.Fatal("expected dispatched job") } + if out.IsParameterized() { + t.Fatal("dispatched job should not be parameterized") + } + if out.ParameterizedJob == nil { + t.Fatal("parameter job config should exist") + } if tc.noEval { return