From 3bcee9db078833857e5aa3de057bc9797f3a42e3 Mon Sep 17 00:00:00 2001 From: lonelyCZ <531187475@qq.com> Date: Sun, 9 Oct 2022 10:25:26 +0800 Subject: [PATCH] Unify the dynamic client name for work_status_controller Signed-off-by: lonelyCZ <531187475@qq.com> --- cmd/agent/app/agent.go | 24 +++++++++---------- .../app/controllermanager.go | 24 +++++++++---------- .../status/workstatus_controller.go | 16 ++++++------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/cmd/agent/app/agent.go b/cmd/agent/app/agent.go index bc69f7ab2..1ef441368 100644 --- a/cmd/agent/app/agent.go +++ b/cmd/agent/app/agent.go @@ -305,18 +305,18 @@ func startExecutionController(ctx controllerscontext.Context) (bool, error) { func startWorkStatusController(ctx controllerscontext.Context) (bool, error) { workStatusController := &status.WorkStatusController{ - Client: ctx.Mgr.GetClient(), - EventRecorder: ctx.Mgr.GetEventRecorderFor(status.WorkStatusControllerName), - RESTMapper: ctx.Mgr.GetRESTMapper(), - InformerManager: genericmanager.GetInstance(), - StopChan: ctx.StopChan, - ObjectWatcher: ctx.ObjectWatcher, - PredicateFunc: helper.NewExecutionPredicateOnAgent(), - ClusterClientSetFunc: util.NewClusterDynamicClientSetForAgent, - ClusterCacheSyncTimeout: ctx.Opts.ClusterCacheSyncTimeout, - ConcurrentWorkStatusSyncs: ctx.Opts.ConcurrentWorkSyncs, - RateLimiterOptions: ctx.Opts.RateLimiterOptions, - ResourceInterpreter: ctx.ResourceInterpreter, + Client: ctx.Mgr.GetClient(), + EventRecorder: ctx.Mgr.GetEventRecorderFor(status.WorkStatusControllerName), + RESTMapper: ctx.Mgr.GetRESTMapper(), + InformerManager: genericmanager.GetInstance(), + StopChan: ctx.StopChan, + ObjectWatcher: ctx.ObjectWatcher, + PredicateFunc: helper.NewExecutionPredicateOnAgent(), + ClusterDynamicClientSetFunc: util.NewClusterDynamicClientSetForAgent, + ClusterCacheSyncTimeout: ctx.Opts.ClusterCacheSyncTimeout, + ConcurrentWorkStatusSyncs: ctx.Opts.ConcurrentWorkSyncs, + RateLimiterOptions: ctx.Opts.RateLimiterOptions, + ResourceInterpreter: ctx.ResourceInterpreter, } workStatusController.RunWorkQueue() if err := workStatusController.SetupWithManager(ctx.Mgr); err != nil { diff --git a/cmd/controller-manager/app/controllermanager.go b/cmd/controller-manager/app/controllermanager.go index ec55e909e..215d2f773 100644 --- a/cmd/controller-manager/app/controllermanager.go +++ b/cmd/controller-manager/app/controllermanager.go @@ -348,18 +348,18 @@ func startExecutionController(ctx controllerscontext.Context) (enabled bool, err func startWorkStatusController(ctx controllerscontext.Context) (enabled bool, err error) { opts := ctx.Opts workStatusController := &status.WorkStatusController{ - Client: ctx.Mgr.GetClient(), - EventRecorder: ctx.Mgr.GetEventRecorderFor(status.WorkStatusControllerName), - RESTMapper: ctx.Mgr.GetRESTMapper(), - InformerManager: genericmanager.GetInstance(), - StopChan: ctx.StopChan, - ObjectWatcher: ctx.ObjectWatcher, - PredicateFunc: helper.NewExecutionPredicate(ctx.Mgr), - ClusterClientSetFunc: util.NewClusterDynamicClientSet, - ClusterCacheSyncTimeout: opts.ClusterCacheSyncTimeout, - ConcurrentWorkStatusSyncs: opts.ConcurrentWorkSyncs, - RateLimiterOptions: ctx.Opts.RateLimiterOptions, - ResourceInterpreter: ctx.ResourceInterpreter, + Client: ctx.Mgr.GetClient(), + EventRecorder: ctx.Mgr.GetEventRecorderFor(status.WorkStatusControllerName), + RESTMapper: ctx.Mgr.GetRESTMapper(), + InformerManager: genericmanager.GetInstance(), + StopChan: ctx.StopChan, + ObjectWatcher: ctx.ObjectWatcher, + PredicateFunc: helper.NewExecutionPredicate(ctx.Mgr), + ClusterDynamicClientSetFunc: util.NewClusterDynamicClientSet, + ClusterCacheSyncTimeout: opts.ClusterCacheSyncTimeout, + ConcurrentWorkStatusSyncs: opts.ConcurrentWorkSyncs, + RateLimiterOptions: ctx.Opts.RateLimiterOptions, + ResourceInterpreter: ctx.ResourceInterpreter, } workStatusController.RunWorkQueue() if err := workStatusController.SetupWithManager(ctx.Mgr); err != nil { diff --git a/pkg/controllers/status/workstatus_controller.go b/pkg/controllers/status/workstatus_controller.go index 25837f260..e5336b93f 100644 --- a/pkg/controllers/status/workstatus_controller.go +++ b/pkg/controllers/status/workstatus_controller.go @@ -47,13 +47,13 @@ type WorkStatusController struct { StopChan <-chan struct{} worker util.AsyncWorker // worker process resources periodic from rateLimitingQueue. // ConcurrentWorkStatusSyncs is the number of Work status that are allowed to sync concurrently. - ConcurrentWorkStatusSyncs int - ObjectWatcher objectwatcher.ObjectWatcher - PredicateFunc predicate.Predicate - ClusterClientSetFunc func(clusterName string, client client.Client) (*util.DynamicClusterClient, error) - ClusterCacheSyncTimeout metav1.Duration - RateLimiterOptions ratelimiterflag.Options - ResourceInterpreter resourceinterpreter.ResourceInterpreter + ConcurrentWorkStatusSyncs int + ObjectWatcher objectwatcher.ObjectWatcher + PredicateFunc predicate.Predicate + ClusterDynamicClientSetFunc func(clusterName string, client client.Client) (*util.DynamicClusterClient, error) + ClusterCacheSyncTimeout metav1.Duration + RateLimiterOptions ratelimiterflag.Options + ResourceInterpreter resourceinterpreter.ResourceInterpreter } // Reconcile performs a full reconciliation for the object referred to by the Request. @@ -462,7 +462,7 @@ func (c *WorkStatusController) getSingleClusterManager(cluster *clusterv1alpha1. // the cache in informer manager should be updated. singleClusterInformerManager := c.InformerManager.GetSingleClusterManager(cluster.Name) if singleClusterInformerManager == nil { - dynamicClusterClient, err := c.ClusterClientSetFunc(cluster.Name, c.Client) + dynamicClusterClient, err := c.ClusterDynamicClientSetFunc(cluster.Name, c.Client) if err != nil { klog.Errorf("Failed to build dynamic cluster client for cluster %s.", cluster.Name) return nil, err