Skip to content

[cluster-autoscaler-release-1.32] fix: add --leader-elect flags back by reverting https://github.com/kubernetes/autoscaler/pull/7233 #7764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
15 changes: 7 additions & 8 deletions cluster-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ func multiStringFlag(name string, usage string) *MultiStringFlag {
}

var (
leaseResourceName = flag.String("lease-resource-name", "cluster-autoscaler", "The lease resource to use in leader election.")
clusterName = flag.String("cluster-name", "", "Autoscaled cluster name, if available")
address = flag.String("address", ":8085", "The address to expose prometheus metrics.")
kubernetes = flag.String("kubernetes", "", "Kubernetes master location. Leave blank for default")
Expand Down Expand Up @@ -692,6 +691,10 @@ func main() {
klog.Fatalf("Failed to add logging feature flags: %v", err)
}

leaderElection := leaderElectionConfiguration()
// Must be called before kube_flag.InitFlags() to ensure leader election flags are parsed and available.
componentopts.BindLeaderElectionFlags(&leaderElection, pflag.CommandLine)

logsapi.AddFlags(loggingConfig, pflag.CommandLine)
featureGate.AddFlag(pflag.CommandLine)
kube_flag.InitFlags()
Expand All @@ -705,10 +708,6 @@ func main() {
}
}

leaderElection := defaultLeaderElectionConfiguration()
leaderElection.LeaderElect = true
componentopts.BindLeaderElectionFlags(&leaderElection, pflag.CommandLine)

logs.InitLogs()
if err := logsapi.ValidateAndApply(loggingConfig, featureGate); err != nil {
klog.Fatalf("Failed to validate and apply logging configuration: %v", err)
Expand Down Expand Up @@ -788,14 +787,14 @@ func main() {
}
}

func defaultLeaderElectionConfiguration() componentbaseconfig.LeaderElectionConfiguration {
func leaderElectionConfiguration() componentbaseconfig.LeaderElectionConfiguration {
return componentbaseconfig.LeaderElectionConfiguration{
LeaderElect: false,
LeaderElect: true,
LeaseDuration: metav1.Duration{Duration: defaultLeaseDuration},
RenewDeadline: metav1.Duration{Duration: defaultRenewDeadline},
RetryPeriod: metav1.Duration{Duration: defaultRetryPeriod},
ResourceLock: resourcelock.LeasesResourceLock,
ResourceName: *leaseResourceName,
ResourceName: "cluster-autoscaler",
}
}

Expand Down
Loading