Skip to content

Commit 2e16f31

Browse files
authored
Merge pull request #4845 from nikParasyr/leader_elect
✨ Add flags for leaderElection timeouts
2 parents a8d7162 + 34be445 commit 2e16f31

File tree

1 file changed

+41
-14
lines changed

1 file changed

+41
-14
lines changed

main.go

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,23 @@ func init() {
9292
}
9393

9494
var (
95-
enableLeaderElection bool
96-
leaderElectionNamespace string
97-
watchNamespace string
98-
watchFilterValue string
99-
profilerAddress string
100-
awsClusterConcurrency int
101-
instanceStateConcurrency int
102-
awsMachineConcurrency int
103-
waitInfraPeriod time.Duration
104-
syncPeriod time.Duration
105-
webhookPort int
106-
webhookCertDir string
107-
healthAddr string
108-
serviceEndpoints string
95+
enableLeaderElection bool
96+
leaderElectionLeaseDuration time.Duration
97+
leaderElectionRenewDeadline time.Duration
98+
leaderElectionRetryPeriod time.Duration
99+
leaderElectionNamespace string
100+
watchNamespace string
101+
watchFilterValue string
102+
profilerAddress string
103+
awsClusterConcurrency int
104+
instanceStateConcurrency int
105+
awsMachineConcurrency int
106+
waitInfraPeriod time.Duration
107+
syncPeriod time.Duration
108+
webhookPort int
109+
webhookCertDir string
110+
healthAddr string
111+
serviceEndpoints string
109112

110113
// maxEKSSyncPeriod is the maximum allowed duration for the sync-period flag when using EKS. It is set to 10 minutes
111114
// because during resync it will create a new AWS auth token which can a maximum life of 15 minutes and this ensures
@@ -171,6 +174,9 @@ func main() {
171174
Scheme: scheme,
172175
Metrics: diagnosticsOpts,
173176
LeaderElection: enableLeaderElection,
177+
LeaseDuration: &leaderElectionLeaseDuration,
178+
RenewDeadline: &leaderElectionRenewDeadline,
179+
RetryPeriod: &leaderElectionRetryPeriod,
174180
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
175181
LeaderElectionID: "controller-leader-elect-capa",
176182
LeaderElectionNamespace: leaderElectionNamespace,
@@ -495,6 +501,27 @@ func initFlags(fs *pflag.FlagSet) {
495501
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.",
496502
)
497503

504+
fs.DurationVar(
505+
&leaderElectionLeaseDuration,
506+
"leader-elect-lease-duration",
507+
15*time.Second,
508+
"Interval at which non-leader candidates will wait to force acquire leadership (duration string)",
509+
)
510+
511+
fs.DurationVar(
512+
&leaderElectionRenewDeadline,
513+
"leader-elect-renew-deadline",
514+
10*time.Second,
515+
"Duration that the leading controller manager will retry refreshing leadership before giving up (duration string)",
516+
)
517+
518+
fs.DurationVar(
519+
&leaderElectionRetryPeriod,
520+
"leader-elect-retry-period",
521+
2*time.Second,
522+
"Duration the LeaderElector clients should wait between tries of actions (duration string)",
523+
)
524+
498525
fs.StringVar(
499526
&watchNamespace,
500527
"namespace",

0 commit comments

Comments
 (0)