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 20, 2018
1 parent e52cabf commit 40fd04c
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 @@ -2184,6 +2184,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 @@ -3449,6 +3456,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 40fd04c

Please sign in to comment.