Validate that min_healthy_time < healthy_deadline
This PR adds a validation check to the update stanza to ensure that the min_healthy_time is feasible.
This commit is contained in:
parent
6d45210b9a
commit
9c655e1208
|
@ -2044,6 +2044,9 @@ func (u *UpdateStrategy) Validate() error {
|
|||
if u.HealthyDeadline <= 0 {
|
||||
multierror.Append(&mErr, fmt.Errorf("Healthy deadline must be greater than zero: %v", u.HealthyDeadline))
|
||||
}
|
||||
if u.MinHealthyTime >= u.HealthyDeadline {
|
||||
multierror.Append(&mErr, fmt.Errorf("Minimum healthy time must be less than healthy deadline: %v > %v", u.MinHealthyTime, u.HealthyDeadline))
|
||||
}
|
||||
if u.Stagger <= 0 {
|
||||
multierror.Append(&mErr, fmt.Errorf("Stagger must be greater than zero: %v", u.Stagger))
|
||||
}
|
||||
|
|
|
@ -1314,7 +1314,7 @@ func TestUpdateStrategy_Validate(t *testing.T) {
|
|||
MaxParallel: -1,
|
||||
HealthCheck: "foo",
|
||||
MinHealthyTime: -10,
|
||||
HealthyDeadline: -10,
|
||||
HealthyDeadline: -15,
|
||||
AutoRevert: false,
|
||||
Canary: -1,
|
||||
}
|
||||
|
@ -1336,6 +1336,9 @@ func TestUpdateStrategy_Validate(t *testing.T) {
|
|||
if !strings.Contains(mErr.Errors[4].Error(), "Healthy deadline must be greater than zero") {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
if !strings.Contains(mErr.Errors[5].Error(), "Minimum healthy time must be less than healthy deadline") {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResource_NetIndex(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue