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

warn destructive update only when count > 1 #13103

Merged
merged 3 commits into from
Sep 2, 2022
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/13103.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
cli: warn destructive update only when count is greater than 1
```
2 changes: 1 addition & 1 deletion nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6724,7 +6724,7 @@ func (tg *TaskGroup) Warnings(j *Job) error {
// Validate the update strategy
if u := tg.Update; u != nil {
// Check the counts are appropriate
if u.MaxParallel > tg.Count && !(j.IsMultiregion() && tg.Count == 0) {
if tg.Count > 1 && u.MaxParallel > tg.Count && !(j.IsMultiregion() && tg.Count == 0) {
mErr.Errors = append(mErr.Errors,
fmt.Errorf("Update max parallel count is greater than task group count (%d > %d). "+
"A destructive change would result in the simultaneous replacement of all allocations.", u.MaxParallel, tg.Count))
Expand Down
30 changes: 30 additions & 0 deletions nomad/structs/structs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,36 @@ func TestJob_Warnings(t *testing.T) {
},
},
},
{
Name: "Update.MaxParallel warning",
Expected: []string{"Update max parallel count is greater than task group count (5 > 2). A destructive change would result in the simultaneous replacement of all allocations."},
Job: &Job{
Type: JobTypeService,
TaskGroups: []*TaskGroup{
{
Count: 2,
Update: &UpdateStrategy{
MaxParallel: 5,
},
},
},
},
},
{
Name: "Update.MaxParallel no warning",
Expected: []string{},
Job: &Job{
Type: JobTypeService,
TaskGroups: []*TaskGroup{
{
Count: 1,
Update: &UpdateStrategy{
MaxParallel: 5,
},
},
},
},
},
}

for _, c := range cases {
Expand Down