From 5782ed99e3b7cd9b4954900562d1284e1f33ed1c Mon Sep 17 00:00:00 2001 From: rohan-019 Date: Fri, 17 Oct 2025 21:16:51 +0530 Subject: [PATCH] reduce unnecessary watch events in execution-status-controller Signed-off-by: rohan-019 --- pkg/controllers/execution/execution_controller.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/controllers/execution/execution_controller.go b/pkg/controllers/execution/execution_controller.go index 28515c11c892..7f734690abee 100644 --- a/pkg/controllers/execution/execution_controller.go +++ b/pkg/controllers/execution/execution_controller.go @@ -36,6 +36,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1" @@ -139,10 +140,15 @@ func (c *Controller) SetupWithManager(mgr controllerruntime.Manager) error { RateLimiter: ratelimiterflag.DefaultControllerRateLimiter[controllerruntime.Request](c.RateLimiterOptions), }) + // Ignore delete events; the deletion process will be handled by the deletion timestamp set. + deleteIgnorePred := predicate.Funcs{ + DeleteFunc: func(event.DeleteEvent) bool { return false }, + } + if c.WorkPredicateFunc != nil { - ctrlBuilder.For(&workv1alpha1.Work{}, builder.WithPredicates(c.WorkPredicateFunc)) + ctrlBuilder.For(&workv1alpha1.Work{}, builder.WithPredicates(c.WorkPredicateFunc, deleteIgnorePred)) } else { - ctrlBuilder.For(&workv1alpha1.Work{}) + ctrlBuilder.For(&workv1alpha1.Work{}, builder.WithPredicates(deleteIgnorePred)) } return ctrlBuilder.Complete(c)