From eb429a597d5a8ba6de88ae7a01630d904ecdfd53 Mon Sep 17 00:00:00 2001 From: lxtywypc Date: Wed, 29 Nov 2023 19:03:38 +0800 Subject: [PATCH] add forType in binding status controller to inherit concurrency declared in global options Signed-off-by: lxtywypc --- pkg/controllers/status/common.go | 9 +++++++++ pkg/controllers/status/crb_status_controller.go | 1 + pkg/controllers/status/rb_status_controller.go | 1 + 3 files changed, 11 insertions(+) diff --git a/pkg/controllers/status/common.go b/pkg/controllers/status/common.go index 067de868f76d..00bcf41f0cf9 100644 --- a/pkg/controllers/status/common.go +++ b/pkg/controllers/status/common.go @@ -21,6 +21,15 @@ import ( "github.com/karmada-io/karmada/pkg/util/restmapper" ) +// Fake predicate for inheriting concurrency of `forType` from global options. +// Matching the feature in later version. +var bindingPredicateFn = builder.WithPredicates(predicate.Funcs{ + CreateFunc: func(event.CreateEvent) bool { return false }, + UpdateFunc: func(event.UpdateEvent) bool { return false }, + DeleteFunc: func(event.DeleteEvent) bool { return false }, + GenericFunc: func(event.GenericEvent) bool { return false }, +}) + var workPredicateFn = builder.WithPredicates(predicate.Funcs{ CreateFunc: func(e event.CreateEvent) bool { return false }, UpdateFunc: func(e event.UpdateEvent) bool { diff --git a/pkg/controllers/status/crb_status_controller.go b/pkg/controllers/status/crb_status_controller.go index 067d09210392..f19aed374a6e 100644 --- a/pkg/controllers/status/crb_status_controller.go +++ b/pkg/controllers/status/crb_status_controller.go @@ -86,6 +86,7 @@ func (c *CRBStatusController) SetupWithManager(mgr controllerruntime.Manager) er }) return controllerruntime.NewControllerManagedBy(mgr).Named("clusterResourceBinding_status_controller"). + For(&workv1alpha2.ClusterResourceBinding{}, bindingPredicateFn). Watches(&workv1alpha1.Work{}, handler.EnqueueRequestsFromMapFunc(workMapFunc), workPredicateFn). WithOptions(controller.Options{RateLimiter: ratelimiterflag.DefaultControllerRateLimiter(c.RateLimiterOptions)}). Complete(c) diff --git a/pkg/controllers/status/rb_status_controller.go b/pkg/controllers/status/rb_status_controller.go index 158928de114c..cff990d62435 100644 --- a/pkg/controllers/status/rb_status_controller.go +++ b/pkg/controllers/status/rb_status_controller.go @@ -88,6 +88,7 @@ func (c *RBStatusController) SetupWithManager(mgr controllerruntime.Manager) err }) return controllerruntime.NewControllerManagedBy(mgr).Named("resourceBinding_status_controller"). + For(&workv1alpha2.ResourceBinding{}, bindingPredicateFn). Watches(&workv1alpha1.Work{}, handler.EnqueueRequestsFromMapFunc(workMapFunc), workPredicateFn). WithOptions(controller.Options{RateLimiter: ratelimiterflag.DefaultControllerRateLimiter(c.RateLimiterOptions)}). Complete(c)