Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent kill_timeout greater than progress_deadline #16761

Merged
merged 6 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/16761.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
core: Prevent `task.kill_timeout` being greater than `update.progress_deadline`
```
17 changes: 17 additions & 0 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5136,6 +5136,12 @@ func (u *UpdateStrategy) IsEmpty() bool {
return true
}

// When the Job is transformed from api to struct, the Update Strategy block is
// copied into the existing task groups, the only things that are passed along
// are MaxParallel and Stagger, because they are enforced at job level.
// That is why checking if MaxParallel is zero is enough to know if the
// update block is empty.

return u.MaxParallel == 0
}

Expand Down Expand Up @@ -6708,6 +6714,8 @@ func (tg *TaskGroup) Validate(j *Job) error {
mErr.Errors = append(mErr.Errors, outer)
}

isTypeService := j.Type == JobTypeService

// Validate the tasks
for _, task := range tg.Tasks {
// Validate the task does not reference undefined volume mounts
Expand All @@ -6727,6 +6735,15 @@ func (tg *TaskGroup) Validate(j *Job) error {
outer := fmt.Errorf("Task %s validation failed: %v", task.Name, err)
mErr.Errors = append(mErr.Errors, outer)
}

// Validate the group's Update Strategy does not conflict with the Task's kill_timeout for service type jobs
if isTypeService && tg.Update != nil {
if task.KillTimeout > tg.Update.ProgressDeadline {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Task %s has a kill timout (%s) longer than the group's progress deadline (%s)",
task.Name, task.KillTimeout.String(), tg.Update.ProgressDeadline.String()))
}
}

}

return mErr.ErrorOrNil()
Expand Down
Loading