Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion cmd/machine-healthcheck/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ import (
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
)

// The default durations for the leader electrion operations.
var (
leaseDuration = 120 * time.Second
renewDealine = 110 * time.Second
retryPeriod = 90 * time.Second
)

func printVersion() {
glog.Infof("Go Version: %s", runtime.Version())
glog.Infof("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH)
Expand Down Expand Up @@ -59,7 +66,7 @@ func main() {

leaderElectLeaseDuration := flag.Duration(
"leader-elect-lease-duration",
90*time.Second,
leaseDuration,
"The duration that non-leader candidates will wait after observing a leadership renewal until attempting to acquire leadership of a led but unrenewed leader slot. This is effectively the maximum duration that a leader can be stopped before it is replaced by another candidate. This is only applicable if leader election is enabled.",
)

Expand All @@ -79,6 +86,9 @@ func main() {
LeaderElectionNamespace: *leaderElectResourceNamespace,
LeaderElectionID: "cluster-api-provider-healthcheck-leader",
LeaseDuration: leaderElectLeaseDuration,
// Slow the default retry and renew election rate to reduce etcd writes at idle: BZ 1858400
RetryPeriod: &retryPeriod,
RenewDeadline: &renewDealine,
}

if *watchNamespace != "" {
Expand Down
12 changes: 11 additions & 1 deletion cmd/machineset/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ const (
defaultWebhookCertdir = "/etc/machine-api-operator/tls"
)

// The default durations for the leader electrion operations.
var (
leaseDuration = 120 * time.Second
renewDealine = 110 * time.Second
retryPeriod = 90 * time.Second
)

func main() {
flag.Set("logtostderr", "true")
klog.InitFlags(nil)
Expand Down Expand Up @@ -75,7 +82,7 @@ func main() {

leaderElectLeaseDuration := flag.Duration(
"leader-elect-lease-duration",
90*time.Second,
leaseDuration,
"The duration that non-leader candidates will wait after observing a leadership renewal until attempting to acquire leadership of a led but unrenewed leader slot. This is effectively the maximum duration that a leader can be stopped before it is replaced by another candidate. This is only applicable if leader election is enabled.",
)

Expand All @@ -102,6 +109,9 @@ func main() {
LeaderElectionNamespace: *leaderElectResourceNamespace,
LeaderElectionID: "cluster-api-provider-machineset-leader",
LeaseDuration: leaderElectLeaseDuration,
// Slow the default retry and renew election rate to reduce etcd writes at idle: BZ 1858400
RetryPeriod: &retryPeriod,
RenewDeadline: &renewDealine,
}

mgr, err := manager.New(cfg, opts)
Expand Down
12 changes: 11 additions & 1 deletion cmd/nodelink-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ import (
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
)

// The default durations for the leader electrion operations.
var (
leaseDuration = 120 * time.Second
renewDealine = 110 * time.Second
retryPeriod = 90 * time.Second
)

func printVersion() {
klog.Infof("Go Version: %s", runtime.Version())
klog.Infof("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH)
Expand Down Expand Up @@ -44,7 +51,7 @@ func main() {

leaderElectLeaseDuration := flag.Duration(
"leader-elect-lease-duration",
90*time.Second,
leaseDuration,
"The duration that non-leader candidates will wait after observing a leadership renewal until attempting to acquire leadership of a led but unrenewed leader slot. This is effectively the maximum duration that a leader can be stopped before it is replaced by another candidate. This is only applicable if leader election is enabled.",
)

Expand All @@ -65,6 +72,9 @@ func main() {
LeaderElectionNamespace: *leaderElectResourceNamespace,
LeaderElectionID: "cluster-api-provider-nodelink-leader",
LeaseDuration: leaderElectLeaseDuration,
// Slow the default retry and renew election rate to reduce etcd writes at idle: BZ 1858400
RetryPeriod: &retryPeriod,
RenewDeadline: &renewDealine,
}
if *watchNamespace != "" {
opts.Namespace = *watchNamespace
Expand Down
12 changes: 11 additions & 1 deletion cmd/vsphere/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ import (
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
)

// The default durations for the leader electrion operations.
var (
leaseDuration = 120 * time.Second
renewDealine = 110 * time.Second
retryPeriod = 90 * time.Second
)

func main() {
var printVersion bool
flag.BoolVar(&printVersion, "version", false, "print version and exit")
Expand All @@ -45,7 +52,7 @@ func main() {

leaderElectLeaseDuration := flag.Duration(
"leader-elect-lease-duration",
90*time.Second,
leaseDuration,
"The duration that non-leader candidates will wait after observing a leadership renewal until attempting to acquire leadership of a led but unrenewed leader slot. This is effectively the maximum duration that a leader can be stopped before it is replaced by another candidate. This is only applicable if leader election is enabled.",
)

Expand Down Expand Up @@ -79,6 +86,9 @@ func main() {
LeaderElectionNamespace: *leaderElectResourceNamespace,
LeaderElectionID: "cluster-api-provider-vsphere-leader",
LeaseDuration: leaderElectLeaseDuration,
// Slow the default retry and renew election rate to reduce etcd writes at idle: BZ 1858400
RetryPeriod: &retryPeriod,
RenewDeadline: &renewDealine,
}

if *watchNamespace != "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func newContainers(config *OperatorConfig, features map[string]bool) []corev1.Co
"--logtostderr=true",
"--v=3",
"--leader-elect=true",
"--leader-elect-lease-duration=90s",
"--leader-elect-lease-duration=120s",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only confusing part to me. we set the lease duration in the controller-runtime config options, do we also need to set on the command line?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use the default if not specified on the CLI. This is useful for development/debugging.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, perfect. thanks for the explanation Mike!

fmt.Sprintf("--namespace=%s", config.TargetNamespace),
}

Expand Down