Skip to content

Commit 6125efd

Browse files
committed
Revert "feat: Add option to enabled warmup when leader election is used (kubernetes-sigs#2740)"
This reverts commit 3c00d41.
1 parent 1119540 commit 6125efd

File tree

4 files changed

+0
-20
lines changed

4 files changed

+0
-20
lines changed

pkg/operator/operator.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import (
4848
"sigs.k8s.io/controller-runtime/pkg/cache"
4949
"sigs.k8s.io/controller-runtime/pkg/client"
5050
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
51-
ctrlconfig "sigs.k8s.io/controller-runtime/pkg/config"
5251
"sigs.k8s.io/controller-runtime/pkg/healthz"
5352
"sigs.k8s.io/controller-runtime/pkg/log"
5453
"sigs.k8s.io/controller-runtime/pkg/manager"
@@ -180,12 +179,6 @@ func NewOperator(o ...option.Function[Options]) (context.Context, *Operator) {
180179
},
181180
},
182181
},
183-
Controller: ctrlconfig.Controller{
184-
// EnableWarmup allows controllers to start their sources (watches/informers) before leader election
185-
// is won. This pre-populates caches and improves leader failover time. Only effective when leader
186-
// election is enabled, so we only set it when both conditions are true.
187-
EnableWarmup: lo.ToPtr(!options.FromContext(ctx).DisableLeaderElection && !options.FromContext(ctx).DisableControllerWarmup),
188-
},
189182
}
190183
if options.FromContext(ctx).EnableProfiling {
191184
// TODO @joinnis: Investigate the mgrOpts.PprofBindAddress that would allow native support for pprof

pkg/operator/options/options.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ type Options struct {
7171
KubeClientQPS int
7272
KubeClientBurst int
7373
EnableProfiling bool
74-
DisableControllerWarmup bool
7574
DisableLeaderElection bool
7675
DisableClusterStateObservability bool
7776
LeaderElectionName string
@@ -115,7 +114,6 @@ func (o *Options) AddFlags(fs *FlagSet) {
115114
fs.IntVar(&o.KubeClientQPS, "kube-client-qps", env.WithDefaultInt("KUBE_CLIENT_QPS", 200), "The smoothed rate of qps to kube-apiserver")
116115
fs.IntVar(&o.KubeClientBurst, "kube-client-burst", env.WithDefaultInt("KUBE_CLIENT_BURST", 300), "The maximum allowed burst of queries to the kube-apiserver")
117116
fs.BoolVarWithEnv(&o.EnableProfiling, "enable-profiling", "ENABLE_PROFILING", false, "Enable the profiling on the metric endpoint")
118-
fs.BoolVarWithEnv(&o.DisableControllerWarmup, "disable-controller-warmup", "DISABLE_CONTROLLER_WARMUP", true, "Disable controller warmup which starts controller sources before leader election is won. Controller warmup pre-populates caches and improves leader failover time.")
119117
fs.BoolVarWithEnv(&o.DisableLeaderElection, "disable-leader-election", "DISABLE_LEADER_ELECTION", false, "Disable the leader election client before executing the main loop. Disable when running replicated components for high availability is not desired.")
120118
fs.BoolVarWithEnv(&o.DisableClusterStateObservability, "disable-cluster-state-observability", "DISABLE_CLUSTER_STATE_OBSERVABILITY", false, "Disable cluster state metrics and events")
121119
fs.StringVar(&o.LeaderElectionName, "leader-election-name", env.WithDefaultString("LEADER_ELECTION_NAME", "karpenter-leader-election"), "Leader election name to create and monitor the lease if running outside the cluster")

pkg/operator/options/suite_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ var _ = Describe("Options", func() {
5252
"KUBE_CLIENT_QPS",
5353
"KUBE_CLIENT_BURST",
5454
"ENABLE_PROFILING",
55-
"DISABLE_CONTROLLER_WARMUP",
5655
"DISABLE_LEADER_ELECTION",
5756
"DISABLE_CLUSTER_STATE_OBSERVABILITY",
5857
"LEADER_ELECTION_NAMESPACE",
@@ -107,7 +106,6 @@ var _ = Describe("Options", func() {
107106
KubeClientQPS: lo.ToPtr(200),
108107
KubeClientBurst: lo.ToPtr(300),
109108
EnableProfiling: lo.ToPtr(false),
110-
DisableControllerWarmup: lo.ToPtr(true),
111109
DisableLeaderElection: lo.ToPtr(false),
112110
DisableClusterStateObservability: lo.ToPtr(false),
113111
LeaderElectionName: lo.ToPtr("karpenter-leader-election"),
@@ -142,7 +140,6 @@ var _ = Describe("Options", func() {
142140
"--kube-client-qps", "0",
143141
"--kube-client-burst", "0",
144142
"--enable-profiling",
145-
"--disable-controller-warmup=false",
146143
"--disable-leader-election=true",
147144
"--disable-cluster-state-observability=true",
148145
"--leader-election-name=karpenter-controller",
@@ -165,7 +162,6 @@ var _ = Describe("Options", func() {
165162
KubeClientQPS: lo.ToPtr(0),
166163
KubeClientBurst: lo.ToPtr(0),
167164
EnableProfiling: lo.ToPtr(true),
168-
DisableControllerWarmup: lo.ToPtr(false),
169165
DisableLeaderElection: lo.ToPtr(true),
170166
DisableClusterStateObservability: lo.ToPtr(true),
171167
LeaderElectionName: lo.ToPtr("karpenter-controller"),
@@ -196,7 +192,6 @@ var _ = Describe("Options", func() {
196192
os.Setenv("KUBE_CLIENT_QPS", "0")
197193
os.Setenv("KUBE_CLIENT_BURST", "0")
198194
os.Setenv("ENABLE_PROFILING", "true")
199-
os.Setenv("DISABLE_CONTROLLER_WARMUP", "false")
200195
os.Setenv("DISABLE_LEADER_ELECTION", "true")
201196
os.Setenv("DISABLE_CLUSTER_STATE_OBSERVABILITY", "true")
202197
os.Setenv("LEADER_ELECTION_NAME", "karpenter-controller")
@@ -223,7 +218,6 @@ var _ = Describe("Options", func() {
223218
KubeClientQPS: lo.ToPtr(0),
224219
KubeClientBurst: lo.ToPtr(0),
225220
EnableProfiling: lo.ToPtr(true),
226-
DisableControllerWarmup: lo.ToPtr(false),
227221
DisableLeaderElection: lo.ToPtr(true),
228222
DisableClusterStateObservability: lo.ToPtr(true),
229223
LeaderElectionName: lo.ToPtr("karpenter-controller"),
@@ -253,7 +247,6 @@ var _ = Describe("Options", func() {
253247
os.Setenv("KUBE_CLIENT_QPS", "0")
254248
os.Setenv("KUBE_CLIENT_BURST", "0")
255249
os.Setenv("ENABLE_PROFILING", "true")
256-
os.Setenv("DISABLE_CONTROLLER_WARMUP", "false")
257250
os.Setenv("DISABLE_LEADER_ELECTION", "true")
258251
os.Setenv("DISABLE_CLUSTER_STATE_OBSERVABILITY", "true")
259252
os.Setenv("MEMORY_LIMIT", "0")
@@ -283,7 +276,6 @@ var _ = Describe("Options", func() {
283276
KubeClientQPS: lo.ToPtr(0),
284277
KubeClientBurst: lo.ToPtr(0),
285278
EnableProfiling: lo.ToPtr(true),
286-
DisableControllerWarmup: lo.ToPtr(false),
287279
DisableLeaderElection: lo.ToPtr(true),
288280
DisableClusterStateObservability: lo.ToPtr(true),
289281
LeaderElectionName: lo.ToPtr("karpenter-leader-election"),
@@ -389,7 +381,6 @@ func expectOptionsMatch(optsA, optsB *options.Options) {
389381
Expect(optsA.KubeClientQPS).To(Equal(optsB.KubeClientQPS))
390382
Expect(optsA.KubeClientBurst).To(Equal(optsB.KubeClientBurst))
391383
Expect(optsA.EnableProfiling).To(Equal(optsB.EnableProfiling))
392-
Expect(optsA.DisableControllerWarmup).To(Equal(optsB.DisableControllerWarmup))
393384
Expect(optsA.DisableLeaderElection).To(Equal(optsB.DisableLeaderElection))
394385
Expect(optsA.DisableClusterStateObservability).To(Equal(optsB.DisableClusterStateObservability))
395386
Expect(optsA.MemoryLimit).To(Equal(optsB.MemoryLimit))

pkg/test/options.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ type OptionsFields struct {
3434
KubeClientQPS *int
3535
KubeClientBurst *int
3636
EnableProfiling *bool
37-
DisableControllerWarmup *bool
3837
DisableLeaderElection *bool
3938
DisableClusterStateObservability *bool
4039
LeaderElectionName *string
@@ -75,7 +74,6 @@ func Options(overrides ...OptionsFields) *options.Options {
7574
KubeClientQPS: lo.FromPtrOr(opts.KubeClientQPS, 200),
7675
KubeClientBurst: lo.FromPtrOr(opts.KubeClientBurst, 300),
7776
EnableProfiling: lo.FromPtrOr(opts.EnableProfiling, false),
78-
DisableControllerWarmup: lo.FromPtrOr(opts.DisableControllerWarmup, true),
7977
DisableLeaderElection: lo.FromPtrOr(opts.DisableLeaderElection, false),
8078
DisableClusterStateObservability: lo.FromPtrOr(opts.DisableClusterStateObservability, false),
8179
MemoryLimit: lo.FromPtrOr(opts.MemoryLimit, -1),

0 commit comments

Comments
 (0)