Skip to content

Commit

Permalink
fix: add clarity to leader election vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Rudoi committed Mar 18, 2020
1 parent 3d1bc04 commit 3faf5e5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 43 deletions.
38 changes: 19 additions & 19 deletions bootstrap/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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.")
Expand Down Expand Up @@ -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,
Expand Down
24 changes: 12 additions & 12 deletions controlplane/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.")
Expand Down Expand Up @@ -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,
Expand Down
24 changes: 12 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.")
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 3faf5e5

Please sign in to comment.