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