nomad: code review comments

This commit is contained in:
Nick Ethier 2018-06-11 13:27:48 -04:00
parent a581cc9c01
commit 50c72adbd7
No known key found for this signature in database
GPG Key ID: 07C1A3ECED90D24A
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -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