Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add flags for leaderElection timeouts #4845

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 41 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,23 @@ func init() {
}

var (
enableLeaderElection bool
leaderElectionNamespace string
watchNamespace string
watchFilterValue string
profilerAddress string
awsClusterConcurrency int
instanceStateConcurrency int
awsMachineConcurrency int
waitInfraPeriod time.Duration
syncPeriod time.Duration
webhookPort int
webhookCertDir string
healthAddr string
serviceEndpoints string
enableLeaderElection bool
leaderElectionLeaseDuration time.Duration
leaderElectionRenewDeadline time.Duration
leaderElectionRetryPeriod time.Duration
leaderElectionNamespace string
watchNamespace string
watchFilterValue string
profilerAddress string
awsClusterConcurrency int
instanceStateConcurrency int
awsMachineConcurrency int
waitInfraPeriod time.Duration
syncPeriod time.Duration
webhookPort int
webhookCertDir string
healthAddr string
serviceEndpoints string

// maxEKSSyncPeriod is the maximum allowed duration for the sync-period flag when using EKS. It is set to 10 minutes
// because during resync it will create a new AWS auth token which can a maximum life of 15 minutes and this ensures
Expand Down Expand Up @@ -170,6 +173,9 @@ func main() {
Scheme: scheme,
Metrics: diagnosticsOpts,
LeaderElection: enableLeaderElection,
LeaseDuration: &leaderElectionLeaseDuration,
RenewDeadline: &leaderElectionRenewDeadline,
RetryPeriod: &leaderElectionRetryPeriod,
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
LeaderElectionID: "controller-leader-elect-capa",
LeaderElectionNamespace: leaderElectionNamespace,
Expand Down Expand Up @@ -494,6 +500,27 @@ func initFlags(fs *pflag.FlagSet) {
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.",
)

fs.DurationVar(
&leaderElectionLeaseDuration,
"leader-elect-lease-duration",
15*time.Second,
"Interval at which non-leader candidates will wait to force acquire leadership (duration string)",
)

fs.DurationVar(
&leaderElectionRenewDeadline,
"leader-elect-renew-deadline",
10*time.Second,
"Duration that the leading controller manager will retry refreshing leadership before giving up (duration string)",
)

fs.DurationVar(
&leaderElectionRetryPeriod,
"leader-elect-retry-period",
2*time.Second,
"Duration the LeaderElector clients should wait between tries of actions (duration string)",
)

fs.StringVar(
&watchNamespace,
"namespace",
Expand Down