diff --git a/cmd/controller-manager/app/controllermanager.go b/cmd/controller-manager/app/controllermanager.go index e3ced42fbc91..6032d3f84e2e 100644 --- a/cmd/controller-manager/app/controllermanager.go +++ b/cmd/controller-manager/app/controllermanager.go @@ -353,23 +353,21 @@ func startClusterStatusController(ctx controllerscontext.Context) (enabled bool, }, } clusterStatusController := &status.ClusterStatusController{ - Client: mgr.GetClient(), - KubeClient: kubeclientset.NewForConfigOrDie(mgr.GetConfig()), - 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. - PredicateFunc: clusterPredicateFunc, - TypedInformerManager: typedmanager.GetInstance(), - GenericInformerManager: genericmanager.GetInstance(), - ClusterClientSetFunc: util.NewClusterClientSet, - ClusterDynamicClientSetFunc: util.NewClusterDynamicClientSet, - ClusterClientOption: ctx.ClusterClientOption, - ClusterStatusUpdateFrequency: opts.ClusterStatusUpdateFrequency, - ClusterLeaseDuration: opts.ClusterLeaseDuration, - ClusterLeaseRenewIntervalFraction: opts.ClusterLeaseRenewIntervalFraction, - ClusterSuccessThreshold: opts.ClusterSuccessThreshold, - ClusterFailureThreshold: opts.ClusterFailureThreshold, - ClusterCacheSyncTimeout: opts.ClusterCacheSyncTimeout, - RateLimiterOptions: ctx.Opts.RateLimiterOptions, - EnableClusterResourceModeling: ctx.Opts.EnableClusterResourceModeling, + Client: mgr.GetClient(), + KubeClient: kubeclientset.NewForConfigOrDie(mgr.GetConfig()), + 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. + PredicateFunc: clusterPredicateFunc, + TypedInformerManager: typedmanager.GetInstance(), + GenericInformerManager: genericmanager.GetInstance(), + ClusterClientSetFunc: util.NewClusterClientSet, + ClusterDynamicClientSetFunc: util.NewClusterDynamicClientSet, + ClusterClientOption: ctx.ClusterClientOption, + ClusterStatusUpdateFrequency: opts.ClusterStatusUpdateFrequency, + ClusterSuccessThreshold: opts.ClusterSuccessThreshold, + ClusterFailureThreshold: opts.ClusterFailureThreshold, + ClusterCacheSyncTimeout: opts.ClusterCacheSyncTimeout, + RateLimiterOptions: ctx.Opts.RateLimiterOptions, + EnableClusterResourceModeling: ctx.Opts.EnableClusterResourceModeling, } if err := clusterStatusController.SetupWithManager(mgr); err != nil { return false, err @@ -912,25 +910,23 @@ func setupControllers(ctx context.Context, mgr controllerruntime.Manager, opts * Mgr: mgr, ObjectWatcher: objectWatcher, Opts: controllerscontext.Options{ - Controllers: opts.Controllers, - ClusterMonitorPeriod: opts.ClusterMonitorPeriod, - ClusterMonitorGracePeriod: opts.ClusterMonitorGracePeriod, - ClusterStartupGracePeriod: opts.ClusterStartupGracePeriod, - ClusterStatusUpdateFrequency: opts.ClusterStatusUpdateFrequency, - ClusterLeaseDuration: opts.ClusterLeaseDuration, - ClusterLeaseRenewIntervalFraction: opts.ClusterLeaseRenewIntervalFraction, - ClusterSuccessThreshold: opts.ClusterSuccessThreshold, - ClusterFailureThreshold: opts.ClusterFailureThreshold, - ClusterCacheSyncTimeout: opts.ClusterCacheSyncTimeout, - SkippedPropagatingNamespaces: opts.SkippedNamespacesRegexps(), - ConcurrentWorkSyncs: opts.ConcurrentWorkSyncs, - EnableTaintManager: opts.EnableTaintManager, - RateLimiterOptions: opts.RateLimiterOpts, - GracefulEvictionTimeout: opts.GracefulEvictionTimeout, - EnableClusterResourceModeling: opts.EnableClusterResourceModeling, - HPAControllerConfiguration: opts.HPAControllerConfiguration, - FederatedResourceQuotaOptions: opts.FederatedResourceQuotaOptions, - ClusterFailoverConfiguration: opts.ClusterFailoverOptions, + Controllers: opts.Controllers, + ClusterMonitorPeriod: opts.ClusterMonitorPeriod, + ClusterMonitorGracePeriod: opts.ClusterMonitorGracePeriod, + ClusterStartupGracePeriod: opts.ClusterStartupGracePeriod, + ClusterStatusUpdateFrequency: opts.ClusterStatusUpdateFrequency, + ClusterSuccessThreshold: opts.ClusterSuccessThreshold, + ClusterFailureThreshold: opts.ClusterFailureThreshold, + ClusterCacheSyncTimeout: opts.ClusterCacheSyncTimeout, + SkippedPropagatingNamespaces: opts.SkippedNamespacesRegexps(), + ConcurrentWorkSyncs: opts.ConcurrentWorkSyncs, + EnableTaintManager: opts.EnableTaintManager, + RateLimiterOptions: opts.RateLimiterOpts, + GracefulEvictionTimeout: opts.GracefulEvictionTimeout, + EnableClusterResourceModeling: opts.EnableClusterResourceModeling, + HPAControllerConfiguration: opts.HPAControllerConfiguration, + FederatedResourceQuotaOptions: opts.FederatedResourceQuotaOptions, + ClusterFailoverConfiguration: opts.ClusterFailoverOptions, }, Context: ctx, DynamicClientSet: dynamicClientSet, diff --git a/cmd/controller-manager/app/options/options.go b/cmd/controller-manager/app/options/options.go index 3596c7091258..ff3c4ce33d1f 100644 --- a/cmd/controller-manager/app/options/options.go +++ b/cmd/controller-manager/app/options/options.go @@ -54,12 +54,6 @@ type Options struct { // ClusterStatusUpdateFrequency is the frequency that controller computes and report cluster status. // It must work with ClusterMonitorGracePeriod(--cluster-monitor-grace-period) in karmada-controller-manager. ClusterStatusUpdateFrequency metav1.Duration - // ClusterLeaseDuration is a duration that candidates for a lease need to wait to force acquire it. - // This is measure against time of last observed lease RenewTime. - ClusterLeaseDuration metav1.Duration - // ClusterLeaseRenewIntervalFraction is a fraction coordinated with ClusterLeaseDuration that - // how long the current holder of a lease has last updated the lease. - ClusterLeaseRenewIntervalFraction float64 // ClusterSuccessThreshold is the duration of successes for the cluster to be considered healthy after recovery. ClusterSuccessThreshold metav1.Duration // 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 flags.DurationVar(&o.LeaderElection.RetryPeriod.Duration, "leader-elect-retry-period", defaultElectionRetryPeriod.Duration, ""+ "The duration the clients should wait between attempting acquisition and renewal "+ "of a leadership. This is only applicable if leader election is enabled.") - flags.DurationVar(&o.ClusterLeaseDuration.Duration, "cluster-lease-duration", 40*time.Second, - "Specifies the expiration period of a cluster lease.") - _ = 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.") - flags.Float64Var(&o.ClusterLeaseRenewIntervalFraction, "cluster-lease-renew-interval-fraction", 0.25, - "Specifies the cluster lease renew interval fraction.") - _ = 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.") flags.DurationVar(&o.ClusterSuccessThreshold.Duration, "cluster-success-threshold", 30*time.Second, "The duration of successes for the cluster to be considered healthy after recovery.") flags.DurationVar(&o.ClusterFailureThreshold.Duration, "cluster-failure-threshold", 30*time.Second, "The duration of failure for the cluster to be considered unhealthy.") flags.DurationVar(&o.ClusterMonitorPeriod.Duration, "cluster-monitor-period", 5*time.Second, diff --git a/cmd/controller-manager/app/options/validation.go b/cmd/controller-manager/app/options/validation.go index 31e33a3134b3..80e8bf78cd02 100644 --- a/cmd/controller-manager/app/options/validation.go +++ b/cmd/controller-manager/app/options/validation.go @@ -37,12 +37,6 @@ func (o *Options) Validate() field.ErrorList { if o.ClusterStatusUpdateFrequency.Duration <= 0 { errs = append(errs, field.Invalid(newPath.Child("ClusterStatusUpdateFrequency"), o.ClusterStatusUpdateFrequency, "must be greater than 0")) } - if o.ClusterLeaseDuration.Duration <= 0 { - errs = append(errs, field.Invalid(newPath.Child("ClusterLeaseDuration"), o.ClusterLeaseDuration, "must be greater than 0")) - } - if o.ClusterLeaseRenewIntervalFraction <= 0 || o.ClusterLeaseRenewIntervalFraction >= 1 { - errs = append(errs, field.Invalid(newPath.Child("ClusterLeaseRenewIntervalFraction"), o.ClusterLeaseRenewIntervalFraction, "must be greater than 0 and less than 1")) - } if o.ClusterMonitorPeriod.Duration <= 0 { errs = append(errs, field.Invalid(newPath.Child("ClusterMonitorPeriod"), o.ClusterMonitorPeriod, "must be greater than 0")) } diff --git a/cmd/controller-manager/app/options/validation_test.go b/cmd/controller-manager/app/options/validation_test.go index 813da319464d..ad7c505e76e3 100644 --- a/cmd/controller-manager/app/options/validation_test.go +++ b/cmd/controller-manager/app/options/validation_test.go @@ -30,13 +30,11 @@ type ModifyOptions func(option *Options) // New an Options with default parameters func New(modifyOptions ModifyOptions) Options { option := Options{ - SkippedPropagatingAPIs: "cluster.karmada.io;policy.karmada.io;work.karmada.io", - ClusterStatusUpdateFrequency: metav1.Duration{Duration: 10 * time.Second}, - ClusterLeaseDuration: metav1.Duration{Duration: 10 * time.Second}, - ClusterMonitorPeriod: metav1.Duration{Duration: 10 * time.Second}, - ClusterMonitorGracePeriod: metav1.Duration{Duration: 10 * time.Second}, - ClusterStartupGracePeriod: metav1.Duration{Duration: 10 * time.Second}, - ClusterLeaseRenewIntervalFraction: 0.25, + SkippedPropagatingAPIs: "cluster.karmada.io;policy.karmada.io;work.karmada.io", + ClusterStatusUpdateFrequency: metav1.Duration{Duration: 10 * time.Second}, + ClusterMonitorPeriod: metav1.Duration{Duration: 10 * time.Second}, + ClusterMonitorGracePeriod: metav1.Duration{Duration: 10 * time.Second}, + ClusterStartupGracePeriod: metav1.Duration{Duration: 10 * time.Second}, FederatedResourceQuotaOptions: FederatedResourceQuotaOptions{ ResourceQuotaSyncPeriod: metav1.Duration{ Duration: 10 * time.Second, @@ -78,24 +76,6 @@ func TestValidateControllerManagerConfiguration(t *testing.T) { }), expectedErrs: field.ErrorList{field.Invalid(newPath.Child("ClusterStatusUpdateFrequency"), metav1.Duration{Duration: -10 * time.Second}, "must be greater than 0")}, }, - "invalid ClusterLeaseDuration": { - opt: New(func(options *Options) { - options.ClusterLeaseDuration.Duration = -40 * time.Second - }), - expectedErrs: field.ErrorList{field.Invalid(newPath.Child("ClusterLeaseDuration"), metav1.Duration{Duration: -40 * time.Second}, "must be greater than 0")}, - }, - "invalid ClusterLeaseRenewIntervalFraction": { - opt: New(func(options *Options) { - options.ClusterLeaseRenewIntervalFraction = 1.2 - }), - expectedErrs: field.ErrorList{field.Invalid(newPath.Child("ClusterLeaseRenewIntervalFraction"), float64(1.2), "must be greater than 0 and less than 1")}, - }, - "invalid ClusterLeaseRenewIntervalFraction (negative)": { - opt: New(func(options *Options) { - options.ClusterLeaseRenewIntervalFraction = -0.1 - }), - expectedErrs: field.ErrorList{field.Invalid(newPath.Child("ClusterLeaseRenewIntervalFraction"), float64(-0.1), "must be greater than 0 and less than 1")}, - }, "invalid ClusterMonitorPeriod": { opt: New(func(options *Options) { options.ClusterMonitorPeriod.Duration = -40 * time.Second