Skip to content

Commit

Permalink
Merge pull request #3081 from clinta/maxparallel0
Browse files Browse the repository at this point in the history
If MaxParallel == 0 default limit to count
  • Loading branch information
dadgar committed Aug 28, 2017
2 parents 472a1f7 + 8486bf2 commit 659d099
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions api/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,12 @@ func (u *UpdateStrategy) Merge(o *UpdateStrategy) {
}

func (u *UpdateStrategy) Canonicalize() {
d := structs.DefaultUpdateStrategy

if u.MaxParallel == nil {
u.MaxParallel = helper.IntToPtr(0)
u.MaxParallel = helper.IntToPtr(d.MaxParallel)
}

d := structs.DefaultUpdateStrategy

if u.Stagger == nil {
u.Stagger = helper.TimeToPtr(d.Stagger)
}
Expand Down
6 changes: 3 additions & 3 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2012,7 +2012,7 @@ var (
// jobs with the old policy or for populating field defaults.
DefaultUpdateStrategy = &UpdateStrategy{
Stagger: 30 * time.Second,
MaxParallel: 0,
MaxParallel: 1,
HealthCheck: UpdateStrategyHealthCheck_Checks,
MinHealthyTime: 10 * time.Second,
HealthyDeadline: 5 * time.Minute,
Expand Down Expand Up @@ -2076,8 +2076,8 @@ func (u *UpdateStrategy) Validate() error {
multierror.Append(&mErr, fmt.Errorf("Invalid health check given: %q", u.HealthCheck))
}

if u.MaxParallel < 0 {
multierror.Append(&mErr, fmt.Errorf("Max parallel can not be less than zero: %d < 0", u.MaxParallel))
if u.MaxParallel < 1 {
multierror.Append(&mErr, fmt.Errorf("Max parallel can not be less than one: %d < 1", u.MaxParallel))
}
if u.Canary < 0 {
multierror.Append(&mErr, fmt.Errorf("Canary count can not be less than zero: %d < 0", u.Canary))
Expand Down
4 changes: 2 additions & 2 deletions nomad/structs/structs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ func TestConstraint_Validate(t *testing.T) {

func TestUpdateStrategy_Validate(t *testing.T) {
u := &UpdateStrategy{
MaxParallel: -1,
MaxParallel: 0,
HealthCheck: "foo",
MinHealthyTime: -10,
HealthyDeadline: -15,
Expand All @@ -1406,7 +1406,7 @@ func TestUpdateStrategy_Validate(t *testing.T) {
if !strings.Contains(mErr.Errors[0].Error(), "Invalid health check given") {
t.Fatalf("err: %s", err)
}
if !strings.Contains(mErr.Errors[1].Error(), "Max parallel can not be less than zero") {
if !strings.Contains(mErr.Errors[1].Error(), "Max parallel can not be less than one") {
t.Fatalf("err: %s", err)
}
if !strings.Contains(mErr.Errors[2].Error(), "Canary count can not be less than zero") {
Expand Down

0 comments on commit 659d099

Please sign in to comment.