Skip to content

Commit

Permalink
validate spread from job/task group validate methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Preetha Appan committed Jul 24, 2018
1 parent 7d5a38f commit 96a67ee
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,13 @@ func (j *Job) Validate() error {
}
}

for idx, spread := range j.Spreads {
if err := spread.Validate(); err != nil {
outer := fmt.Errorf("Spread %d validation failed: %s", idx+1, err)
mErr.Errors = append(mErr.Errors, outer)
}
}

// Check for duplicate task groups
taskGroups := make(map[string]int)
for idx, tg := range j.TaskGroups {
Expand Down Expand Up @@ -3459,6 +3466,13 @@ func (tg *TaskGroup) Validate(j *Job) error {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Task Group %v should have a restart policy", tg.Name))
}

for idx, spread := range tg.Spreads {
if err := spread.Validate(); err != nil {
outer := fmt.Errorf("Spread %d validation failed: %s", idx+1, err)
mErr.Errors = append(mErr.Errors, outer)
}
}

if j.Type == JobTypeSystem {
if tg.ReschedulePolicy != nil {
mErr.Errors = append(mErr.Errors, fmt.Errorf("System jobs should not have a reschedule policy"))
Expand Down

0 comments on commit 96a67ee

Please sign in to comment.