From 9c64f488ba4200759de53e28f9e4acd0708569d2 Mon Sep 17 00:00:00 2001 From: Michael McCune Date: Tue, 25 Aug 2020 10:42:10 -0400 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. --- 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 b65b69c10b..bc2e7ba2d5 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -33,6 +33,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/runtime/signals" ) +// The default durations for the leader election operations. +var ( + leaseDuration = 120 * time.Second + renewDeadline = 110 * time.Second + retryPeriod = 20 * time.Second +) + func main() { flag.Set("logtostderr", "true") @@ -62,7 +69,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.", ) metricsAddress := flag.String( @@ -88,6 +95,9 @@ func main() { LeaderElectionID: "cluster-api-provider-openstack-leader", LeaseDuration: leaderElectLeaseDuration, MetricsBindAddress: *metricsAddress, + // Slow the default retry and renew election rate to reduce etcd writes at idle: BZ 1858400 + RetryPeriod: &retryPeriod, + RenewDeadline: &renewDeadline, } if *watchNamespace != "" { opts.Namespace = *watchNamespace