Skip to content

Commit 3d3888d

Browse files
authored
Merge pull request #7271 from dahuo98/remove-deprecated-flags-from-karmada-controller-manager
Remove deprecated flags in controller manager options
2 parents 981e922 + 67d01c0 commit 3d3888d

File tree

4 files changed

+37
-79
lines changed

4 files changed

+37
-79
lines changed

cmd/controller-manager/app/controllermanager.go

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -353,23 +353,21 @@ func startClusterStatusController(ctx controllerscontext.Context) (enabled bool,
353353
},
354354
}
355355
clusterStatusController := &status.ClusterStatusController{
356-
Client: mgr.GetClient(),
357-
KubeClient: kubeclientset.NewForConfigOrDie(mgr.GetConfig()),
358-
EventRecorder: mgr.GetEventRecorderFor(status.ControllerName), //nolint:staticcheck // Note: GetEventRecorderFor is deprecated in controller-runtime v0.23.0 in favor of GetEventRecorder. This changes event API from v1 events to events.k8s.io. We need to migrate carefully, especially considering the impact on users and RBAC permission changes in installation/deployment tools.
359-
PredicateFunc: clusterPredicateFunc,
360-
TypedInformerManager: typedmanager.GetInstance(),
361-
GenericInformerManager: genericmanager.GetInstance(),
362-
ClusterClientSetFunc: util.NewClusterClientSet,
363-
ClusterDynamicClientSetFunc: util.NewClusterDynamicClientSet,
364-
ClusterClientOption: ctx.ClusterClientOption,
365-
ClusterStatusUpdateFrequency: opts.ClusterStatusUpdateFrequency,
366-
ClusterLeaseDuration: opts.ClusterLeaseDuration,
367-
ClusterLeaseRenewIntervalFraction: opts.ClusterLeaseRenewIntervalFraction,
368-
ClusterSuccessThreshold: opts.ClusterSuccessThreshold,
369-
ClusterFailureThreshold: opts.ClusterFailureThreshold,
370-
ClusterCacheSyncTimeout: opts.ClusterCacheSyncTimeout,
371-
RateLimiterOptions: ctx.Opts.RateLimiterOptions,
372-
EnableClusterResourceModeling: ctx.Opts.EnableClusterResourceModeling,
356+
Client: mgr.GetClient(),
357+
KubeClient: kubeclientset.NewForConfigOrDie(mgr.GetConfig()),
358+
EventRecorder: mgr.GetEventRecorderFor(status.ControllerName), //nolint:staticcheck // Note: GetEventRecorderFor is deprecated in controller-runtime v0.23.0 in favor of GetEventRecorder. This changes event API from v1 events to events.k8s.io. We need to migrate carefully, especially considering the impact on users and RBAC permission changes in installation/deployment tools.
359+
PredicateFunc: clusterPredicateFunc,
360+
TypedInformerManager: typedmanager.GetInstance(),
361+
GenericInformerManager: genericmanager.GetInstance(),
362+
ClusterClientSetFunc: util.NewClusterClientSet,
363+
ClusterDynamicClientSetFunc: util.NewClusterDynamicClientSet,
364+
ClusterClientOption: ctx.ClusterClientOption,
365+
ClusterStatusUpdateFrequency: opts.ClusterStatusUpdateFrequency,
366+
ClusterSuccessThreshold: opts.ClusterSuccessThreshold,
367+
ClusterFailureThreshold: opts.ClusterFailureThreshold,
368+
ClusterCacheSyncTimeout: opts.ClusterCacheSyncTimeout,
369+
RateLimiterOptions: ctx.Opts.RateLimiterOptions,
370+
EnableClusterResourceModeling: ctx.Opts.EnableClusterResourceModeling,
373371
}
374372
if err := clusterStatusController.SetupWithManager(mgr); err != nil {
375373
return false, err
@@ -912,25 +910,23 @@ func setupControllers(ctx context.Context, mgr controllerruntime.Manager, opts *
912910
Mgr: mgr,
913911
ObjectWatcher: objectWatcher,
914912
Opts: controllerscontext.Options{
915-
Controllers: opts.Controllers,
916-
ClusterMonitorPeriod: opts.ClusterMonitorPeriod,
917-
ClusterMonitorGracePeriod: opts.ClusterMonitorGracePeriod,
918-
ClusterStartupGracePeriod: opts.ClusterStartupGracePeriod,
919-
ClusterStatusUpdateFrequency: opts.ClusterStatusUpdateFrequency,
920-
ClusterLeaseDuration: opts.ClusterLeaseDuration,
921-
ClusterLeaseRenewIntervalFraction: opts.ClusterLeaseRenewIntervalFraction,
922-
ClusterSuccessThreshold: opts.ClusterSuccessThreshold,
923-
ClusterFailureThreshold: opts.ClusterFailureThreshold,
924-
ClusterCacheSyncTimeout: opts.ClusterCacheSyncTimeout,
925-
SkippedPropagatingNamespaces: opts.SkippedNamespacesRegexps(),
926-
ConcurrentWorkSyncs: opts.ConcurrentWorkSyncs,
927-
EnableTaintManager: opts.EnableTaintManager,
928-
RateLimiterOptions: opts.RateLimiterOpts,
929-
GracefulEvictionTimeout: opts.GracefulEvictionTimeout,
930-
EnableClusterResourceModeling: opts.EnableClusterResourceModeling,
931-
HPAControllerConfiguration: opts.HPAControllerConfiguration,
932-
FederatedResourceQuotaOptions: opts.FederatedResourceQuotaOptions,
933-
ClusterFailoverConfiguration: opts.ClusterFailoverOptions,
913+
Controllers: opts.Controllers,
914+
ClusterMonitorPeriod: opts.ClusterMonitorPeriod,
915+
ClusterMonitorGracePeriod: opts.ClusterMonitorGracePeriod,
916+
ClusterStartupGracePeriod: opts.ClusterStartupGracePeriod,
917+
ClusterStatusUpdateFrequency: opts.ClusterStatusUpdateFrequency,
918+
ClusterSuccessThreshold: opts.ClusterSuccessThreshold,
919+
ClusterFailureThreshold: opts.ClusterFailureThreshold,
920+
ClusterCacheSyncTimeout: opts.ClusterCacheSyncTimeout,
921+
SkippedPropagatingNamespaces: opts.SkippedNamespacesRegexps(),
922+
ConcurrentWorkSyncs: opts.ConcurrentWorkSyncs,
923+
EnableTaintManager: opts.EnableTaintManager,
924+
RateLimiterOptions: opts.RateLimiterOpts,
925+
GracefulEvictionTimeout: opts.GracefulEvictionTimeout,
926+
EnableClusterResourceModeling: opts.EnableClusterResourceModeling,
927+
HPAControllerConfiguration: opts.HPAControllerConfiguration,
928+
FederatedResourceQuotaOptions: opts.FederatedResourceQuotaOptions,
929+
ClusterFailoverConfiguration: opts.ClusterFailoverOptions,
934930
},
935931
Context: ctx,
936932
DynamicClientSet: dynamicClientSet,

cmd/controller-manager/app/options/options.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ type Options struct {
5454
// ClusterStatusUpdateFrequency is the frequency that controller computes and report cluster status.
5555
// It must work with ClusterMonitorGracePeriod(--cluster-monitor-grace-period) in karmada-controller-manager.
5656
ClusterStatusUpdateFrequency metav1.Duration
57-
// ClusterLeaseDuration is a duration that candidates for a lease need to wait to force acquire it.
58-
// This is measure against time of last observed lease RenewTime.
59-
ClusterLeaseDuration metav1.Duration
60-
// ClusterLeaseRenewIntervalFraction is a fraction coordinated with ClusterLeaseDuration that
61-
// how long the current holder of a lease has last updated the lease.
62-
ClusterLeaseRenewIntervalFraction float64
6357
// ClusterSuccessThreshold is the duration of successes for the cluster to be considered healthy after recovery.
6458
ClusterSuccessThreshold metav1.Duration
6559
// ClusterFailureThreshold is the duration of failure for the cluster to be considered unhealthy.
@@ -185,12 +179,6 @@ func (o *Options) AddFlags(flags *pflag.FlagSet, allControllers, disabledByDefau
185179
flags.DurationVar(&o.LeaderElection.RetryPeriod.Duration, "leader-elect-retry-period", defaultElectionRetryPeriod.Duration, ""+
186180
"The duration the clients should wait between attempting acquisition and renewal "+
187181
"of a leadership. This is only applicable if leader election is enabled.")
188-
flags.DurationVar(&o.ClusterLeaseDuration.Duration, "cluster-lease-duration", 40*time.Second,
189-
"Specifies the expiration period of a cluster lease.")
190-
_ = flags.MarkDeprecated("cluster-lease-duration", "The flag --cluster-lease-duration has been marked deprecated because it has never been used, and will be removed in a future release.")
191-
flags.Float64Var(&o.ClusterLeaseRenewIntervalFraction, "cluster-lease-renew-interval-fraction", 0.25,
192-
"Specifies the cluster lease renew interval fraction.")
193-
_ = flags.MarkDeprecated("cluster-lease-renew-interval-fraction", "The flag --cluster-lease-renew-interval-fraction has been marked deprecated because it has never been used, and will be removed in a future release.")
194182
flags.DurationVar(&o.ClusterSuccessThreshold.Duration, "cluster-success-threshold", 30*time.Second, "The duration of successes for the cluster to be considered healthy after recovery.")
195183
flags.DurationVar(&o.ClusterFailureThreshold.Duration, "cluster-failure-threshold", 30*time.Second, "The duration of failure for the cluster to be considered unhealthy.")
196184
flags.DurationVar(&o.ClusterMonitorPeriod.Duration, "cluster-monitor-period", 5*time.Second,

cmd/controller-manager/app/options/validation.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ func (o *Options) Validate() field.ErrorList {
3737
if o.ClusterStatusUpdateFrequency.Duration <= 0 {
3838
errs = append(errs, field.Invalid(newPath.Child("ClusterStatusUpdateFrequency"), o.ClusterStatusUpdateFrequency, "must be greater than 0"))
3939
}
40-
if o.ClusterLeaseDuration.Duration <= 0 {
41-
errs = append(errs, field.Invalid(newPath.Child("ClusterLeaseDuration"), o.ClusterLeaseDuration, "must be greater than 0"))
42-
}
43-
if o.ClusterLeaseRenewIntervalFraction <= 0 || o.ClusterLeaseRenewIntervalFraction >= 1 {
44-
errs = append(errs, field.Invalid(newPath.Child("ClusterLeaseRenewIntervalFraction"), o.ClusterLeaseRenewIntervalFraction, "must be greater than 0 and less than 1"))
45-
}
4640
if o.ClusterMonitorPeriod.Duration <= 0 {
4741
errs = append(errs, field.Invalid(newPath.Child("ClusterMonitorPeriod"), o.ClusterMonitorPeriod, "must be greater than 0"))
4842
}

cmd/controller-manager/app/options/validation_test.go

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@ type ModifyOptions func(option *Options)
3030
// New an Options with default parameters
3131
func New(modifyOptions ModifyOptions) Options {
3232
option := Options{
33-
SkippedPropagatingAPIs: "cluster.karmada.io;policy.karmada.io;work.karmada.io",
34-
ClusterStatusUpdateFrequency: metav1.Duration{Duration: 10 * time.Second},
35-
ClusterLeaseDuration: metav1.Duration{Duration: 10 * time.Second},
36-
ClusterMonitorPeriod: metav1.Duration{Duration: 10 * time.Second},
37-
ClusterMonitorGracePeriod: metav1.Duration{Duration: 10 * time.Second},
38-
ClusterStartupGracePeriod: metav1.Duration{Duration: 10 * time.Second},
39-
ClusterLeaseRenewIntervalFraction: 0.25,
33+
SkippedPropagatingAPIs: "cluster.karmada.io;policy.karmada.io;work.karmada.io",
34+
ClusterStatusUpdateFrequency: metav1.Duration{Duration: 10 * time.Second},
35+
ClusterMonitorPeriod: metav1.Duration{Duration: 10 * time.Second},
36+
ClusterMonitorGracePeriod: metav1.Duration{Duration: 10 * time.Second},
37+
ClusterStartupGracePeriod: metav1.Duration{Duration: 10 * time.Second},
4038
FederatedResourceQuotaOptions: FederatedResourceQuotaOptions{
4139
ResourceQuotaSyncPeriod: metav1.Duration{
4240
Duration: 10 * time.Second,
@@ -78,24 +76,6 @@ func TestValidateControllerManagerConfiguration(t *testing.T) {
7876
}),
7977
expectedErrs: field.ErrorList{field.Invalid(newPath.Child("ClusterStatusUpdateFrequency"), metav1.Duration{Duration: -10 * time.Second}, "must be greater than 0")},
8078
},
81-
"invalid ClusterLeaseDuration": {
82-
opt: New(func(options *Options) {
83-
options.ClusterLeaseDuration.Duration = -40 * time.Second
84-
}),
85-
expectedErrs: field.ErrorList{field.Invalid(newPath.Child("ClusterLeaseDuration"), metav1.Duration{Duration: -40 * time.Second}, "must be greater than 0")},
86-
},
87-
"invalid ClusterLeaseRenewIntervalFraction": {
88-
opt: New(func(options *Options) {
89-
options.ClusterLeaseRenewIntervalFraction = 1.2
90-
}),
91-
expectedErrs: field.ErrorList{field.Invalid(newPath.Child("ClusterLeaseRenewIntervalFraction"), float64(1.2), "must be greater than 0 and less than 1")},
92-
},
93-
"invalid ClusterLeaseRenewIntervalFraction (negative)": {
94-
opt: New(func(options *Options) {
95-
options.ClusterLeaseRenewIntervalFraction = -0.1
96-
}),
97-
expectedErrs: field.ErrorList{field.Invalid(newPath.Child("ClusterLeaseRenewIntervalFraction"), float64(-0.1), "must be greater than 0 and less than 1")},
98-
},
9979
"invalid ClusterMonitorPeriod": {
10080
opt: New(func(options *Options) {
10181
options.ClusterMonitorPeriod.Duration = -40 * time.Second

0 commit comments

Comments
 (0)