mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
prevent zero for leader election timeouts
This commit is contained in:
parent
eacf6f05b1
commit
7288e8828f
@ -74,6 +74,16 @@ func NewLeaderElector(lec LeaderElectionConfig) (*LeaderElector, error) {
|
|||||||
if lec.RenewDeadline <= time.Duration(JitterFactor*float64(lec.RetryPeriod)) {
|
if lec.RenewDeadline <= time.Duration(JitterFactor*float64(lec.RetryPeriod)) {
|
||||||
return nil, fmt.Errorf("renewDeadline must be greater than retryPeriod*JitterFactor")
|
return nil, fmt.Errorf("renewDeadline must be greater than retryPeriod*JitterFactor")
|
||||||
}
|
}
|
||||||
|
if lec.LeaseDuration < 1 {
|
||||||
|
return nil, fmt.Errorf("leaseDuration must be greater than zero")
|
||||||
|
}
|
||||||
|
if lec.RenewDeadline < 1 {
|
||||||
|
return nil, fmt.Errorf("renewDeadline must be greater than zero")
|
||||||
|
}
|
||||||
|
if lec.RetryPeriod < 1 {
|
||||||
|
return nil, fmt.Errorf("retryPeriod must be greater than zero")
|
||||||
|
}
|
||||||
|
|
||||||
if lec.Lock == nil {
|
if lec.Lock == nil {
|
||||||
return nil, fmt.Errorf("Lock must not be nil.")
|
return nil, fmt.Errorf("Lock must not be nil.")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user