Merge pull request #3081 from clinta/maxparallel0

If MaxParallel == 0 default limit to count
This commit is contained in:
Alex Dadgar 2017-08-28 12:42:50 -07:00 committed by GitHub
commit e6bf8f8e75
3 changed files with 9 additions and 9 deletions

View File

@ -372,12 +372,12 @@ func (u *UpdateStrategy) Merge(o *UpdateStrategy) {
} }
func (u *UpdateStrategy) Canonicalize() { func (u *UpdateStrategy) Canonicalize() {
if u.MaxParallel == nil {
u.MaxParallel = helper.IntToPtr(0)
}
d := structs.DefaultUpdateStrategy d := structs.DefaultUpdateStrategy
if u.MaxParallel == nil {
u.MaxParallel = helper.IntToPtr(d.MaxParallel)
}
if u.Stagger == nil { if u.Stagger == nil {
u.Stagger = helper.TimeToPtr(d.Stagger) u.Stagger = helper.TimeToPtr(d.Stagger)
} }

View File

@ -2012,7 +2012,7 @@ var (
// jobs with the old policy or for populating field defaults. // jobs with the old policy or for populating field defaults.
DefaultUpdateStrategy = &UpdateStrategy{ DefaultUpdateStrategy = &UpdateStrategy{
Stagger: 30 * time.Second, Stagger: 30 * time.Second,
MaxParallel: 0, MaxParallel: 1,
HealthCheck: UpdateStrategyHealthCheck_Checks, HealthCheck: UpdateStrategyHealthCheck_Checks,
MinHealthyTime: 10 * time.Second, MinHealthyTime: 10 * time.Second,
HealthyDeadline: 5 * time.Minute, HealthyDeadline: 5 * time.Minute,
@ -2076,8 +2076,8 @@ func (u *UpdateStrategy) Validate() error {
multierror.Append(&mErr, fmt.Errorf("Invalid health check given: %q", u.HealthCheck)) multierror.Append(&mErr, fmt.Errorf("Invalid health check given: %q", u.HealthCheck))
} }
if u.MaxParallel < 0 { if u.MaxParallel < 1 {
multierror.Append(&mErr, fmt.Errorf("Max parallel can not be less than zero: %d < 0", u.MaxParallel)) multierror.Append(&mErr, fmt.Errorf("Max parallel can not be less than one: %d < 1", u.MaxParallel))
} }
if u.Canary < 0 { if u.Canary < 0 {
multierror.Append(&mErr, fmt.Errorf("Canary count can not be less than zero: %d < 0", u.Canary)) multierror.Append(&mErr, fmt.Errorf("Canary count can not be less than zero: %d < 0", u.Canary))

View File

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