Skip to content
Open
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
13 changes: 13 additions & 0 deletions cmd/common/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/machine-config-controller/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down