diff --git a/staging/src/k8s.io/component-base/config/options/leaderelectionconfig.go b/staging/src/k8s.io/component-base/config/options/leaderelectionconfig.go index 5c671a1b79b..bf2a44a0a83 100644 --- a/staging/src/k8s.io/component-base/config/options/leaderelectionconfig.go +++ b/staging/src/k8s.io/component-base/config/options/leaderelectionconfig.go @@ -35,7 +35,7 @@ func BindLeaderElectionFlags(l *config.LeaderElectionConfiguration, fs *pflag.Fl "election is enabled.") fs.DurationVar(&l.RenewDeadline.Duration, "leader-elect-renew-deadline", l.RenewDeadline.Duration, ""+ "The interval between attempts by the acting master to renew a leadership slot "+ - "before it stops leading. This must be less than or equal to the lease duration. "+ + "before it stops leading. This must be less than the lease duration. "+ "This is only applicable if leader election is enabled.") fs.DurationVar(&l.RetryPeriod.Duration, "leader-elect-retry-period", l.RetryPeriod.Duration, ""+ "The duration the clients should wait between attempting acquisition and renewal "+ diff --git a/staging/src/k8s.io/component-base/config/validation/validation.go b/staging/src/k8s.io/component-base/config/validation/validation.go index 4db15ea647d..1bee0a01f0a 100644 --- a/staging/src/k8s.io/component-base/config/validation/validation.go +++ b/staging/src/k8s.io/component-base/config/validation/validation.go @@ -45,7 +45,7 @@ func ValidateLeaderElectionConfiguration(cc *config.LeaderElectionConfiguration, if cc.RetryPeriod.Duration <= 0 { allErrs = append(allErrs, field.Invalid(fldPath.Child("retryPeriod"), cc.RetryPeriod, "must be greater than zero")) } - if cc.LeaseDuration.Duration < cc.RenewDeadline.Duration { + if cc.LeaseDuration.Duration <= cc.RenewDeadline.Duration { allErrs = append(allErrs, field.Invalid(fldPath.Child("leaseDuration"), cc.RenewDeadline, "LeaseDuration must be greater than RenewDeadline")) } if len(cc.ResourceLock) == 0 { diff --git a/staging/src/k8s.io/component-base/config/validation/validation_test.go b/staging/src/k8s.io/component-base/config/validation/validation_test.go index fc5a589941a..951a9e8b888 100644 --- a/staging/src/k8s.io/component-base/config/validation/validation_test.go +++ b/staging/src/k8s.io/component-base/config/validation/validation_test.go @@ -79,6 +79,9 @@ func TestValidateLeaderElectionConfiguration(t *testing.T) { ResourceName: "name", } + renewDeadlineEqualToLeaseDuration := validConfig.DeepCopy() + renewDeadlineEqualToLeaseDuration.RenewDeadline = metav1.Duration{Duration: 30 * time.Second} + renewDeadlineExceedsLeaseDuration := validConfig.DeepCopy() renewDeadlineExceedsLeaseDuration.RenewDeadline = metav1.Duration{Duration: 45 * time.Second} @@ -122,6 +125,10 @@ func TestValidateLeaderElectionConfiguration(t *testing.T) { expectedToFail: false, config: LeaderElectButLeaderElectNotEnabled, }, + "bad-renew-deadline-equal-to-lease-duration": { + expectedToFail: true, + config: renewDeadlineEqualToLeaseDuration, + }, "bad-renew-deadline-exceeds-lease-duration": { expectedToFail: true, config: renewDeadlineExceedsLeaseDuration,