Skip to content

Commit dfb1056

Browse files
committed
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.
1 parent 7f69c2e commit dfb1056

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cmd/manager/main.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ import (
4040
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
4141
)
4242

43+
// The default durations for the leader election operations.
44+
var (
45+
leaseDuration = 120 * time.Second
46+
renewDeadline = 110 * time.Second
47+
retryPeriod = 20 * time.Second
48+
)
49+
4350
func main() {
4451
klog.InitFlags(nil)
4552

@@ -76,7 +83,7 @@ func main() {
7683

7784
leaderElectLeaseDuration := flag.Duration(
7885
"leader-elect-lease-duration",
79-
90*time.Second,
86+
leaseDuration,
8087
"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.",
8188
)
8289
flag.Parse()
@@ -104,6 +111,9 @@ func main() {
104111
LeaderElectionID: "controller-leader-election-capbm",
105112
LeaderElectionNamespace: *leaderElectResourceNamespace,
106113
LeaseDuration: leaderElectLeaseDuration,
114+
// Slow the default retry and renew election rate to reduce etcd writes at idle: BZ 1858400
115+
RetryPeriod: &retryPeriod,
116+
RenewDeadline: &renewDeadline,
107117
}
108118
if *watchNamespace != "" {
109119
opts.Namespace = *watchNamespace

0 commit comments

Comments
 (0)