diff --git a/cmd/common/helpers.go b/cmd/common/helpers.go index a7ad807128..32adddefdd 100644 --- a/cmd/common/helpers.go +++ b/cmd/common/helpers.go @@ -79,6 +79,19 @@ func GetLeaderElectionConfig(restcfg *rest.Config) configv1.LeaderElection { return defaultLeaderElection } +// GetDefaultLeaderElectionConfig returns HA default leader election timings regardless of +// cluster topology. Use this for components that run a single replica and have no lease +// contention, where the inflated SNO timings only add unnecessary recovery latency. +func GetDefaultLeaderElectionConfig() configv1.LeaderElection { + defaultLeaderElection := leaderelection.LeaderElectionDefaulting( + configv1.LeaderElection{}, + "", "", + ) + klog.Infof("Using HA default leader election timings (LeaseDuration=%s, RetryPeriod=%s)", + defaultLeaderElection.LeaseDuration.Duration, defaultLeaderElection.RetryPeriod.Duration) + return defaultLeaderElection +} + // SignalHandler catches SIGINT/SIGTERM signals and makes sure the passed context gets cancelled when those signals happen. This allows us to use a // context to shut down our operations cleanly when we are signalled to shutdown. func SignalHandler(runCancel context.CancelFunc) { diff --git a/cmd/machine-config-controller/start.go b/cmd/machine-config-controller/start.go index f9a022d230..71a547e63c 100644 --- a/cmd/machine-config-controller/start.go +++ b/cmd/machine-config-controller/start.go @@ -181,7 +181,7 @@ func runStartCmd(_ *cobra.Command, _ []string) { <-ctx.Done() } - leaderElectionCfg := common.GetLeaderElectionConfig(cb.GetBuilderConfig()) + leaderElectionCfg := common.GetDefaultLeaderElectionConfig() leaderelection.RunOrDie(runContext, leaderelection.LeaderElectionConfig{ Lock: common.CreateResourceLock(cb, startOpts.resourceLockNamespace, componentName),