diff --git a/cmd/machine-healthcheck/main.go b/cmd/machine-healthcheck/main.go index 812f8b61fb..ded2554d13 100644 --- a/cmd/machine-healthcheck/main.go +++ b/cmd/machine-healthcheck/main.go @@ -20,6 +20,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/runtime/signals" ) +// The default durations for the leader electrion operations. +var ( + leaseDuration = 120 * time.Second + renewDealine = 110 * time.Second + retryPeriod = 90 * time.Second +) + func printVersion() { glog.Infof("Go Version: %s", runtime.Version()) glog.Infof("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH) @@ -59,7 +66,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.", ) @@ -79,6 +86,9 @@ func main() { LeaderElectionNamespace: *leaderElectResourceNamespace, LeaderElectionID: "cluster-api-provider-healthcheck-leader", LeaseDuration: leaderElectLeaseDuration, + // Slow the default retry and renew election rate to reduce etcd writes at idle: BZ 1858400 + RetryPeriod: &retryPeriod, + RenewDeadline: &renewDealine, } if *watchNamespace != "" { diff --git a/cmd/machineset/main.go b/cmd/machineset/main.go index 109b306bbb..a975fb2474 100644 --- a/cmd/machineset/main.go +++ b/cmd/machineset/main.go @@ -39,6 +39,13 @@ const ( defaultWebhookCertdir = "/etc/machine-api-operator/tls" ) +// The default durations for the leader electrion operations. +var ( + leaseDuration = 120 * time.Second + renewDealine = 110 * time.Second + retryPeriod = 90 * time.Second +) + func main() { flag.Set("logtostderr", "true") klog.InitFlags(nil) @@ -75,7 +82,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.", ) @@ -102,6 +109,9 @@ func main() { LeaderElectionNamespace: *leaderElectResourceNamespace, LeaderElectionID: "cluster-api-provider-machineset-leader", LeaseDuration: leaderElectLeaseDuration, + // Slow the default retry and renew election rate to reduce etcd writes at idle: BZ 1858400 + RetryPeriod: &retryPeriod, + RenewDeadline: &renewDealine, } mgr, err := manager.New(cfg, opts) diff --git a/cmd/nodelink-controller/main.go b/cmd/nodelink-controller/main.go index 99572c5a54..28367dc825 100644 --- a/cmd/nodelink-controller/main.go +++ b/cmd/nodelink-controller/main.go @@ -15,6 +15,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/runtime/signals" ) +// The default durations for the leader electrion operations. +var ( + leaseDuration = 120 * time.Second + renewDealine = 110 * time.Second + retryPeriod = 90 * time.Second +) + func printVersion() { klog.Infof("Go Version: %s", runtime.Version()) klog.Infof("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH) @@ -44,7 +51,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.", ) @@ -65,6 +72,9 @@ func main() { LeaderElectionNamespace: *leaderElectResourceNamespace, LeaderElectionID: "cluster-api-provider-nodelink-leader", LeaseDuration: leaderElectLeaseDuration, + // Slow the default retry and renew election rate to reduce etcd writes at idle: BZ 1858400 + RetryPeriod: &retryPeriod, + RenewDeadline: &renewDealine, } if *watchNamespace != "" { opts.Namespace = *watchNamespace diff --git a/cmd/vsphere/main.go b/cmd/vsphere/main.go index 89d3e767f6..f44807572a 100644 --- a/cmd/vsphere/main.go +++ b/cmd/vsphere/main.go @@ -20,6 +20,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/runtime/signals" ) +// The default durations for the leader electrion operations. +var ( + leaseDuration = 120 * time.Second + renewDealine = 110 * time.Second + retryPeriod = 90 * time.Second +) + func main() { var printVersion bool flag.BoolVar(&printVersion, "version", false, "print version and exit") @@ -45,7 +52,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.", ) @@ -79,6 +86,9 @@ func main() { LeaderElectionNamespace: *leaderElectResourceNamespace, LeaderElectionID: "cluster-api-provider-vsphere-leader", LeaseDuration: leaderElectLeaseDuration, + // Slow the default retry and renew election rate to reduce etcd writes at idle: BZ 1858400 + RetryPeriod: &retryPeriod, + RenewDeadline: &renewDealine, } if *watchNamespace != "" { diff --git a/pkg/operator/sync.go b/pkg/operator/sync.go index 02b5d75c88..b4c455dcbd 100644 --- a/pkg/operator/sync.go +++ b/pkg/operator/sync.go @@ -446,7 +446,7 @@ func newContainers(config *OperatorConfig, features map[string]bool) []corev1.Co "--logtostderr=true", "--v=3", "--leader-elect=true", - "--leader-elect-lease-duration=90s", + "--leader-elect-lease-duration=120s", fmt.Sprintf("--namespace=%s", config.TargetNamespace), }