diff --git a/pkg/controller/networkpolicy/add.go b/pkg/controller/networkpolicy/add.go index 14f8043d65d..259eabbcbfc 100644 --- a/pkg/controller/networkpolicy/add.go +++ b/pkg/controller/networkpolicy/add.go @@ -81,7 +81,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, runtimeCluster cluster.Cl WithOptions(controller.Options{ MaxConcurrentReconciles: pointer.IntDeref(r.ConcurrentSyncs, 0), }). - Watches( + WatchesRawSource( source.Kind(runtimeCluster.GetCache(), &corev1.Namespace{}), &handler.EnqueueRequestForObject{}, builder.WithPredicates(predicateutils.ForEventTypes(predicateutils.Create, predicateutils.Update)), diff --git a/pkg/gardenlet/controller/backupbucket/add.go b/pkg/gardenlet/controller/backupbucket/add.go index 57ac374198d..dd7b6103645 100644 --- a/pkg/gardenlet/controller/backupbucket/add.go +++ b/pkg/gardenlet/controller/backupbucket/add.go @@ -66,7 +66,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, gardenCluster cluster.Clu MaxConcurrentReconciles: pointer.IntDeref(r.Config.ConcurrentSyncs, 0), RateLimiter: r.RateLimiter, }). - Watches( + WatchesRawSource( source.Kind(gardenCluster.GetCache(), &gardencorev1beta1.BackupBucket{}), controllerutils.EnqueueCreateEventsOncePer24hDuration(r.Clock), builder.WithPredicates( diff --git a/pkg/gardenlet/controller/backupentry/add.go b/pkg/gardenlet/controller/backupentry/add.go index e8c2f805246..8aa4647d877 100644 --- a/pkg/gardenlet/controller/backupentry/add.go +++ b/pkg/gardenlet/controller/backupentry/add.go @@ -69,7 +69,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, gardenCluster, seedCluste MaxConcurrentReconciles: pointer.IntDeref(r.Config.ConcurrentSyncs, 0), RateLimiter: r.RateLimiter, }). - Watches( + WatchesRawSource( source.Kind(gardenCluster.GetCache(), &gardencorev1beta1.BackupEntry{}), controllerutils.EnqueueCreateEventsOncePer24hDuration(r.Clock), builder.WithPredicates( diff --git a/pkg/gardenlet/controller/bastion/add.go b/pkg/gardenlet/controller/bastion/add.go index 4dbd145a15a..87113cf61a0 100644 --- a/pkg/gardenlet/controller/bastion/add.go +++ b/pkg/gardenlet/controller/bastion/add.go @@ -61,7 +61,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, gardenCluster, seedCluste MaxConcurrentReconciles: pointer.IntDeref(r.Config.ConcurrentSyncs, 0), RateLimiter: r.RateLimiter, }). - Watches( + WatchesRawSource( source.Kind(gardenCluster.GetCache(), &operationsv1alpha1.Bastion{}), &handler.EnqueueRequestForObject{}, builder.WithPredicates(predicate.GenerationChangedPredicate{}), diff --git a/pkg/gardenlet/controller/controllerinstallation/care/add.go b/pkg/gardenlet/controller/controllerinstallation/care/add.go index a6f340b269c..274adfc5298 100644 --- a/pkg/gardenlet/controller/controllerinstallation/care/add.go +++ b/pkg/gardenlet/controller/controllerinstallation/care/add.go @@ -66,7 +66,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, gardenCluster, seedCluste // if going into exponential backoff, wait at most the configured sync period RateLimiter: workqueue.NewWithMaxWaitRateLimiter(workqueue.DefaultControllerRateLimiter(), r.Config.SyncPeriod.Duration), }). - Watches( + WatchesRawSource( source.Kind(gardenCluster.GetCache(), &gardencorev1beta1.ControllerInstallation{}), &handler.EnqueueRequestForObject{}, builder.WithPredicates(predicateutils.ForEventTypes(predicateutils.Create)), diff --git a/pkg/gardenlet/controller/controllerinstallation/controllerinstallation/add.go b/pkg/gardenlet/controller/controllerinstallation/controllerinstallation/add.go index 8b0837a5694..1a50d1a589e 100644 --- a/pkg/gardenlet/controller/controllerinstallation/controllerinstallation/add.go +++ b/pkg/gardenlet/controller/controllerinstallation/controllerinstallation/add.go @@ -53,7 +53,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, gardenCluster cluster.Clu WithOptions(controller.Options{ MaxConcurrentReconciles: pointer.IntDeref(r.Config.ConcurrentSyncs, 0), }). - Watches( + WatchesRawSource( source.Kind(gardenCluster.GetCache(), &gardencorev1beta1.ControllerInstallation{}), &handler.EnqueueRequestForObject{}, builder.WithPredicates( diff --git a/pkg/gardenlet/controller/managedseed/add.go b/pkg/gardenlet/controller/managedseed/add.go index 060055ed133..801e5bed00a 100644 --- a/pkg/gardenlet/controller/managedseed/add.go +++ b/pkg/gardenlet/controller/managedseed/add.go @@ -99,7 +99,7 @@ func (r *Reconciler) AddToManager( WithOptions(controller.Options{ MaxConcurrentReconciles: pointer.IntDeref(r.Config.Controllers.ManagedSeed.ConcurrentSyncs, 0), }). - Watches( + WatchesRawSource( source.Kind(gardenCluster.GetCache(), &seedmanagementv1alpha1.ManagedSeed{}), r.EnqueueWithJitterDelay(), builder.WithPredicates( diff --git a/pkg/gardenlet/controller/seed/care/add.go b/pkg/gardenlet/controller/seed/care/add.go index be00d78e3ab..6995d248957 100644 --- a/pkg/gardenlet/controller/seed/care/add.go +++ b/pkg/gardenlet/controller/seed/care/add.go @@ -63,7 +63,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, gardenCluster, seedCluste // if going into exponential backoff, wait at most the configured sync period RateLimiter: workqueue.NewWithMaxWaitRateLimiter(workqueue.DefaultControllerRateLimiter(), r.Config.SyncPeriod.Duration), }). - Watches( + WatchesRawSource( source.Kind(gardenCluster.GetCache(), &gardencorev1beta1.Seed{}), &handler.EnqueueRequestForObject{}, builder.WithPredicates( diff --git a/pkg/gardenlet/controller/seed/lease/add.go b/pkg/gardenlet/controller/seed/lease/add.go index fdd5906a8fd..bfd7010daab 100644 --- a/pkg/gardenlet/controller/seed/lease/add.go +++ b/pkg/gardenlet/controller/seed/lease/add.go @@ -52,7 +52,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, gardenCluster cluster.Clu MaxConcurrentReconciles: 1, RateLimiter: workqueue.NewItemExponentialFailureRateLimiter(time.Millisecond, 2*time.Second), }). - Watches( + WatchesRawSource( source.Kind(gardenCluster.GetCache(), &gardencorev1beta1.Seed{}), &handler.EnqueueRequestForObject{}, builder.WithPredicates( diff --git a/pkg/gardenlet/controller/seed/seed/add.go b/pkg/gardenlet/controller/seed/seed/add.go index 8b1ada2447d..c612a7ad3f4 100644 --- a/pkg/gardenlet/controller/seed/seed/add.go +++ b/pkg/gardenlet/controller/seed/seed/add.go @@ -69,7 +69,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, gardenCluster cluster.Clu WithOptions(controller.Options{ MaxConcurrentReconciles: 1, }). - Watches( + WatchesRawSource( source.Kind(gardenCluster.GetCache(), &gardencorev1beta1.Seed{}), &handler.EnqueueRequestForObject{}, builder.WithPredicates( diff --git a/pkg/gardenlet/controller/shoot/care/add.go b/pkg/gardenlet/controller/shoot/care/add.go index 4a7e2081dfa..e7619e02091 100644 --- a/pkg/gardenlet/controller/shoot/care/add.go +++ b/pkg/gardenlet/controller/shoot/care/add.go @@ -55,7 +55,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, gardenCluster cluster.Clu // if going into exponential backoff, wait at most the configured sync period RateLimiter: workqueue.NewWithMaxWaitRateLimiter(workqueue.DefaultControllerRateLimiter(), r.Config.Controllers.ShootCare.SyncPeriod.Duration), }). - Watches( + WatchesRawSource( source.Kind(gardenCluster.GetCache(), &gardencorev1beta1.Shoot{}), r.EventHandler(), builder.WithPredicates( diff --git a/pkg/gardenlet/controller/shootstate/extensions/add.go b/pkg/gardenlet/controller/shootstate/extensions/add.go index be96a4e229e..cfd9507a66f 100644 --- a/pkg/gardenlet/controller/shootstate/extensions/add.go +++ b/pkg/gardenlet/controller/shootstate/extensions/add.go @@ -52,7 +52,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, gardenCluster, seedCluste WithOptions(controller.Options{ MaxConcurrentReconciles: pointer.IntDeref(r.Config.ConcurrentSyncs, 0), }). - Watches( + WatchesRawSource( source.Kind(seedCluster.GetCache(), r.NewObjectFunc()), &handler.EnqueueRequestForObject{}, builder.WithPredicates( diff --git a/pkg/resourcemanager/controller/csrapprover/add.go b/pkg/resourcemanager/controller/csrapprover/add.go index 5527863f679..9f8aaea1d8e 100644 --- a/pkg/resourcemanager/controller/csrapprover/add.go +++ b/pkg/resourcemanager/controller/csrapprover/add.go @@ -47,7 +47,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, sourceCluster, targetClus WithOptions(controller.Options{ MaxConcurrentReconciles: pointer.IntDeref(r.Config.ConcurrentSyncs, 0), }). - Watches( + WatchesRawSource( source.Kind(targetCluster.GetCache(), &certificatesv1.CertificateSigningRequest{}), &handler.EnqueueRequestForObject{}, builder.WithPredicates( diff --git a/pkg/resourcemanager/controller/garbagecollector/add.go b/pkg/resourcemanager/controller/garbagecollector/add.go index 87e0e7cc2ac..5530b3b6963 100644 --- a/pkg/resourcemanager/controller/garbagecollector/add.go +++ b/pkg/resourcemanager/controller/garbagecollector/add.go @@ -47,6 +47,6 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, targetCluster cluster.Clu WithOptions(controller.Options{ MaxConcurrentReconciles: 1, }). - Watches(controllerutils.EnqueueOnce, nil). + WatchesRawSource(controllerutils.EnqueueOnce, nil). Complete(r) } diff --git a/pkg/resourcemanager/controller/health/progressing/add.go b/pkg/resourcemanager/controller/health/progressing/add.go index e8eeae31035..6008d69cd99 100644 --- a/pkg/resourcemanager/controller/health/progressing/add.go +++ b/pkg/resourcemanager/controller/health/progressing/add.go @@ -84,15 +84,15 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, sourceCluster, targetClus // in Shoot clusters, because they are controlled by the end user. In this case, we rely on periodic syncs only. // If we want to have immediate updates for managed resources in Shoots in the future as well, we could consider // adding labels to managed resources and watch them explicitly. - b = b.Watches( + b = b.WatchesRawSource( source.Kind(targetCluster.GetCache(), &appsv1.Deployment{}), mapper.EnqueueRequestsFrom(utils.MapToOriginManagedResource(clusterID), mapper.UpdateWithNew, c.GetLogger()), builder.WithPredicates(r.ProgressingStatusChanged()), - ).Watches( + ).WatchesRawSource( source.Kind(targetCluster.GetCache(), &appsv1.StatefulSet{}), mapper.EnqueueRequestsFrom(utils.MapToOriginManagedResource(clusterID), mapper.UpdateWithNew, c.GetLogger()), builder.WithPredicates(r.ProgressingStatusChanged()), - ).Watches( + ).WatchesRawSource( source.Kind(targetCluster.GetCache(), &appsv1.DaemonSet{}), mapper.EnqueueRequestsFrom(utils.MapToOriginManagedResource(clusterID), mapper.UpdateWithNew, c.GetLogger()), builder.WithPredicates(r.ProgressingStatusChanged()), diff --git a/pkg/resourcemanager/controller/networkpolicy/add.go b/pkg/resourcemanager/controller/networkpolicy/add.go index 2e6aa9d4234..00243413843 100644 --- a/pkg/resourcemanager/controller/networkpolicy/add.go +++ b/pkg/resourcemanager/controller/networkpolicy/add.go @@ -66,7 +66,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, targetCluster cluster.Clu WithOptions(controller.Options{ MaxConcurrentReconciles: pointer.IntDeref(r.Config.ConcurrentSyncs, 0), }). - Watches( + WatchesRawSource( source.Kind(targetCluster.GetCache(), &corev1.Service{}), &handler.EnqueueRequestForObject{}, builder.WithPredicates(r.ServicePredicate()), diff --git a/pkg/resourcemanager/controller/node/add.go b/pkg/resourcemanager/controller/node/add.go index 5cab81aefd2..51405873ab9 100644 --- a/pkg/resourcemanager/controller/node/add.go +++ b/pkg/resourcemanager/controller/node/add.go @@ -48,7 +48,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, targetCluster cluster.Clu WithOptions(controller.Options{ MaxConcurrentReconciles: pointer.IntDeref(r.Config.ConcurrentSyncs, 0), }). - Watches( + WatchesRawSource( source.Kind(targetCluster.GetCache(), &corev1.Node{}), &handler.EnqueueRequestForObject{}, builder.WithPredicates(r.NodePredicate()), diff --git a/pkg/resourcemanager/controller/secret/add.go b/pkg/resourcemanager/controller/secret/add.go index 9a2516945e5..8640b7805a5 100644 --- a/pkg/resourcemanager/controller/secret/add.go +++ b/pkg/resourcemanager/controller/secret/add.go @@ -52,7 +52,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, sourceCluster cluster.Clu // with too many unnecessary requests for all secrets in cluster/namespace. resourcemanagerpredicate.HasFinalizer(r.ClassFilter.FinalizerName()), )). - Watches( + WatchesRawSource( &source.Kind{Type: &resourcesv1alpha1.ManagedResource{}}, mapper.EnqueueRequestsFrom(mapper.MapFunc(r.MapManagedResourcesToSecrets), mapper.UpdateWithOldAndNew, logr.Discard()), builder.WithPredicates(predicate.GenerationChangedPredicate{}), diff --git a/pkg/resourcemanager/controller/tokeninvalidator/add.go b/pkg/resourcemanager/controller/tokeninvalidator/add.go index 8441f8ea137..e6af5b6b6e4 100644 --- a/pkg/resourcemanager/controller/tokeninvalidator/add.go +++ b/pkg/resourcemanager/controller/tokeninvalidator/add.go @@ -59,7 +59,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager, targetCluster cluster.Clu MaxConcurrentReconciles: 1, RateLimiter: r.RateLimiter, }). - Watches( + WatchesRawSource( source.Kind(targetCluster.GetCache(), secret), &handler.EnqueueRequestForObject{}, builder.WithPredicates(r.SecretPredicate()),