Skip to content

Commit

Permalink
Use WatchesRawSource instead of Watches
Browse files Browse the repository at this point in the history
  • Loading branch information
ary1992 committed Jun 19, 2023
1 parent 0d2ea18 commit 7e022b9
Show file tree
Hide file tree
Showing 19 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/networkpolicy/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
2 changes: 1 addition & 1 deletion pkg/gardenlet/controller/backupbucket/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pkg/gardenlet/controller/backupentry/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pkg/gardenlet/controller/bastion/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pkg/gardenlet/controller/managedseed/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pkg/gardenlet/controller/seed/care/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pkg/gardenlet/controller/seed/lease/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pkg/gardenlet/controller/seed/seed/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pkg/gardenlet/controller/shoot/care/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pkg/gardenlet/controller/shootstate/extensions/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pkg/resourcemanager/controller/csrapprover/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pkg/resourcemanager/controller/garbagecollector/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 3 additions & 3 deletions pkg/resourcemanager/controller/health/progressing/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
2 changes: 1 addition & 1 deletion pkg/resourcemanager/controller/networkpolicy/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
2 changes: 1 addition & 1 deletion pkg/resourcemanager/controller/node/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
2 changes: 1 addition & 1 deletion pkg/resourcemanager/controller/secret/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}),
Expand Down
2 changes: 1 addition & 1 deletion pkg/resourcemanager/controller/tokeninvalidator/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit 7e022b9

Please sign in to comment.