From 7ccf74933b75106c666865a1c7ff01fd84054e94 Mon Sep 17 00:00:00 2001 From: Danil-Grigorev Date: Wed, 12 Aug 2020 19:27:41 +0200 Subject: [PATCH] Slow the default lease retry and renew rate for machine controller Prevent machine controllers from writing in etcd at idle too often by setting 120s lease, 20s retry and 110s deadline on all renewals. Higher values cause tests to flake. BZ 1858403 --- cmd/manager/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/manager/main.go b/cmd/manager/main.go index e0ccc96b85..dbc16b8a4c 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -37,6 +37,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" ) +// The default durations for the leader electrion operations. +var ( + leaseDuration = 120 * time.Second + renewDealine = 110 * time.Second + retryPeriod = 20 * time.Second +) + func main() { printVersion := flag.Bool( "version", @@ -70,7 +77,7 @@ func main() { leaderElectLeaseDuration := flag.Duration( "leader-elect-lease-duration", - 90*time.Second, + leaseDuration, "The duration that non-leader candidates will wait after observing a leadership renewal until attempting to acquire leadership of a led but unrenewed leader slot. This is effectively the maximum duration that a leader can be stopped before it is replaced by another candidate. This is only applicable if leader election is enabled.", ) @@ -105,6 +112,9 @@ func main() { HealthProbeBindAddress: *healthAddr, SyncPeriod: &syncPeriod, MetricsBindAddress: *metricsAddress, + // Slow the default retry and renew election rate to reduce etcd writes at idle: BZ 1858400 + RetryPeriod: &retryPeriod, + RenewDeadline: &renewDealine, } if *watchNamespace != "" {