From 3faf5e591278a06520d56385284aabb1302d5d35 Mon Sep 17 00:00:00 2001 From: Andrew Rudoi Date: Wed, 18 Mar 2020 08:39:17 -0700 Subject: [PATCH] fix: add clarity to leader election vars --- bootstrap/kubeadm/main.go | 38 ++++++++++++++++++------------------ controlplane/kubeadm/main.go | 24 +++++++++++------------ main.go | 24 +++++++++++------------ 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/bootstrap/kubeadm/main.go b/bootstrap/kubeadm/main.go index 4360607b0969..f6f912186492 100644 --- a/bootstrap/kubeadm/main.go +++ b/bootstrap/kubeadm/main.go @@ -59,16 +59,16 @@ func init() { } var ( - metricsAddr string - enableLeaderElection bool - leaseDuration time.Duration - renewDeadline time.Duration - retryPeriod time.Duration - watchNamespace string - profilerAddress string - kubeadmConfigConcurrency int - syncPeriod time.Duration - webhookPort int + metricsAddr string + enableLeaderElection bool + leaderElectionLeaseDuration time.Duration + leaderElectionRenewDeadline time.Duration + leaderElectionRetryPeriod time.Duration + watchNamespace string + profilerAddress string + kubeadmConfigConcurrency int + syncPeriod time.Duration + webhookPort int ) func InitFlags(fs *pflag.FlagSet) { @@ -78,14 +78,14 @@ func InitFlags(fs *pflag.FlagSet) { fs.BoolVar(&enableLeaderElection, "enable-leader-election", false, "Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.") - fs.DurationVar(&leaseDuration, "lease-duration", 15*time.Second, - "Interval at which non-leader candidates will wait to force acquire leadership (e.g. 20s)") + fs.DurationVar(&leaderElectionLeaseDuration, "lease-duration", 15*time.Second, + "Interval at which non-leader candidates will wait to force acquire leadership (duration string)") - fs.DurationVar(&renewDeadline, "renew-deadline", 10*time.Second, - "Duration that the acting master will retry refreshing leadership before giving up (e.g. 15s)") + fs.DurationVar(&leaderElectionRenewDeadline, "renew-deadline", 10*time.Second, + "Duration that the acting master will retry refreshing leadership before giving up (duration string)") - fs.DurationVar(&retryPeriod, "retry-period", 2*time.Second, - "Duration the LeaderElector clients should wait between tries of actions (e.g. 5s)") + fs.DurationVar(&leaderElectionRetryPeriod, "retry-period", 2*time.Second, + "Duration the LeaderElector clients should wait between tries of actions (duration string)") fs.StringVar(&watchNamespace, "namespace", "", "Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.") @@ -127,9 +127,9 @@ func main() { MetricsBindAddress: metricsAddr, LeaderElection: enableLeaderElection, LeaderElectionID: "kubeadm-bootstrap-manager-leader-election-capi", - LeaseDuration: &leaseDuration, - RenewDeadline: &renewDeadline, - RetryPeriod: &retryPeriod, + LeaseDuration: &leaderElectionLeaseDuration, + RenewDeadline: &leaderElectionRenewDeadline, + RetryPeriod: &leaderElectionRetryPeriod, Namespace: watchNamespace, SyncPeriod: &syncPeriod, NewClient: newClientFunc, diff --git a/controlplane/kubeadm/main.go b/controlplane/kubeadm/main.go index c93fcecad2d4..e7ae580ed250 100644 --- a/controlplane/kubeadm/main.go +++ b/controlplane/kubeadm/main.go @@ -58,9 +58,9 @@ func init() { var ( metricsAddr string enableLeaderElection bool - leaseDuration time.Duration - renewDeadline time.Duration - retryPeriod time.Duration + leaderElectionLeaseDuration time.Duration + leaderElectionRenewDeadline time.Duration + leaderElectionRetryPeriod time.Duration watchNamespace string profilerAddress string kubeadmControlPlaneConcurrency int @@ -76,14 +76,14 @@ func InitFlags(fs *pflag.FlagSet) { fs.BoolVar(&enableLeaderElection, "enable-leader-election", false, "Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.") - fs.DurationVar(&leaseDuration, "lease-duration", 15*time.Second, - "Interval at which non-leader candidates will wait to force acquire leadership (e.g. 20s)") + fs.DurationVar(&leaderElectionLeaseDuration, "lease-duration", 15*time.Second, + "Interval at which non-leader candidates will wait to force acquire leadership (duration string)") - fs.DurationVar(&renewDeadline, "renew-deadline", 10*time.Second, - "Duration that the acting master will retry refreshing leadership before giving up (e.g. 15s)") + fs.DurationVar(&leaderElectionRenewDeadline, "renew-deadline", 10*time.Second, + "Duration that the acting master will retry refreshing leadership before giving up (duration string)") - fs.DurationVar(&retryPeriod, "retry-period", 2*time.Second, - "Duration the LeaderElector clients should wait between tries of actions (e.g. 5s)") + fs.DurationVar(&leaderElectionRetryPeriod, "retry-period", 2*time.Second, + "Duration the LeaderElector clients should wait between tries of actions (duration string)") fs.StringVar(&watchNamespace, "namespace", "", "Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.") @@ -119,9 +119,9 @@ func main() { MetricsBindAddress: metricsAddr, LeaderElection: enableLeaderElection, LeaderElectionID: "kubeadm-control-plane-manager-leader-election-capi", - LeaseDuration: &leaseDuration, - RenewDeadline: &renewDeadline, - RetryPeriod: &retryPeriod, + LeaseDuration: &leaderElectionLeaseDuration, + RenewDeadline: &leaderElectionRenewDeadline, + RetryPeriod: &leaderElectionRetryPeriod, Namespace: watchNamespace, SyncPeriod: &syncPeriod, NewClient: newClientFunc, diff --git a/main.go b/main.go index 1bd197511a78..65f531436c5a 100644 --- a/main.go +++ b/main.go @@ -50,9 +50,9 @@ var ( // flags metricsAddr string enableLeaderElection bool - leaseDuration time.Duration - renewDeadline time.Duration - retryPeriod time.Duration + leaderElectionLeaseDuration time.Duration + leaderElectionRenewDeadline time.Duration + leaderElectionRetryPeriod time.Duration watchNamespace string profilerAddress string clusterConcurrency int @@ -85,14 +85,14 @@ func InitFlags(fs *pflag.FlagSet) { fs.BoolVar(&enableLeaderElection, "enable-leader-election", false, "Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.") - fs.DurationVar(&leaseDuration, "lease-duration", 15*time.Second, - "Interval at which non-leader candidates will wait to force acquire leadership (e.g. 20s)") + fs.DurationVar(&leaderElectionLeaseDuration, "lease-duration", 15*time.Second, + "Interval at which non-leader candidates will wait to force acquire leadership (duration string)") - fs.DurationVar(&renewDeadline, "renew-deadline", 10*time.Second, - "Duration that the acting master will retry refreshing leadership before giving up (e.g. 15s)") + fs.DurationVar(&leaderElectionRenewDeadline, "renew-deadline", 10*time.Second, + "Duration that the acting master will retry refreshing leadership before giving up (duration string)") - fs.DurationVar(&retryPeriod, "retry-period", 2*time.Second, - "Duration the LeaderElector clients should wait between tries of actions (e.g. 5s)") + fs.DurationVar(&leaderElectionRetryPeriod, "retry-period", 2*time.Second, + "Duration the LeaderElector clients should wait between tries of actions (duration string)") fs.StringVar(&watchNamespace, "namespace", "", "Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.") @@ -149,9 +149,9 @@ func main() { MetricsBindAddress: metricsAddr, LeaderElection: enableLeaderElection, LeaderElectionID: "controller-leader-election-capi", - LeaseDuration: &leaseDuration, - RenewDeadline: &renewDeadline, - RetryPeriod: &retryPeriod, + LeaseDuration: &leaderElectionLeaseDuration, + RenewDeadline: &leaderElectionRenewDeadline, + RetryPeriod: &leaderElectionRetryPeriod, Namespace: watchNamespace, SyncPeriod: &syncPeriod, NewClient: newClientFunc,