Skip to content

Commit 29bc0f8

Browse files
authored
Merge pull request kubernetes-csi#313 from RaunakShah/le_config
Add command line arguments to configure leader election options
2 parents 9193818 + eaab87c commit 29bc0f8

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ Note that the external-attacher does not scale with more replicas. Only one exte
7878

7979
* `--kube-api-burst`: The number of requests to the Kubernetes API server, exceeding the QPS, that can be sent at any given time. Defaults to `10`.
8080

81+
* `--leader-election-lease-duration <duration>`: Duration, in seconds, that non-leader candidates will wait to force acquire leadership. Defaults to 15 seconds.
82+
83+
* `--leader-election-renew-deadline <duration>`: Duration, in seconds, that the acting leader will retry refreshing leadership before giving up. Defaults to 10 seconds.
84+
85+
* `--leader-election-retry-period <duration>`: Duration, in seconds, the LeaderElector clients should wait between tries of actions. Defaults to 5 seconds.
86+
8187
#### Other recognized arguments
8288

8389
* `--kubeconfig <path>`: Path to Kubernetes client configuration that the external-attacher uses to connect to Kubernetes API server. When omitted, default token provided by Kubernetes will be used. This option is useful only when the external-attacher does not run as a Kubernetes pod, e.g. for debugging.

cmd/csi-attacher/main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ var (
6262
retryIntervalStart = flag.Duration("retry-interval-start", time.Second, "Initial retry interval of failed create volume or deletion. It doubles with each failure, up to retry-interval-max.")
6363
retryIntervalMax = flag.Duration("retry-interval-max", 5*time.Minute, "Maximum retry interval of failed create volume or deletion.")
6464

65-
enableLeaderElection = flag.Bool("leader-election", false, "Enable leader election.")
66-
leaderElectionNamespace = flag.String("leader-election-namespace", "", "Namespace where the leader election resource lives. Defaults to the pod namespace if not set.")
65+
enableLeaderElection = flag.Bool("leader-election", false, "Enable leader election.")
66+
leaderElectionNamespace = flag.String("leader-election-namespace", "", "Namespace where the leader election resource lives. Defaults to the pod namespace if not set.")
67+
leaderElectionLeaseDuration = flag.Duration("leader-election-lease-duration", 15*time.Second, "Duration, in seconds, that non-leader candidates will wait to force acquire leadership. Defaults to 15 seconds.")
68+
leaderElectionRenewDeadline = flag.Duration("leader-election-renew-deadline", 10*time.Second, "Duration, in seconds, that the acting leader will retry refreshing leadership before giving up. Defaults to 10 seconds.")
69+
leaderElectionRetryPeriod = flag.Duration("leader-election-retry-period", 5*time.Second, "Duration, in seconds, the LeaderElector clients should wait between tries of actions. Defaults to 5 seconds.")
6770

6871
reconcileSync = flag.Duration("reconcile-sync", 1*time.Minute, "Resync interval of the VolumeAttachment reconciler.")
6972

@@ -261,6 +264,10 @@ func main() {
261264
le.WithNamespace(*leaderElectionNamespace)
262265
}
263266

267+
le.WithLeaseDuration(*leaderElectionLeaseDuration)
268+
le.WithRenewDeadline(*leaderElectionRenewDeadline)
269+
le.WithRetryPeriod(*leaderElectionRetryPeriod)
270+
264271
if err := le.Run(); err != nil {
265272
klog.Fatalf("failed to initialize leader election: %v", err)
266273
}

0 commit comments

Comments
 (0)