diff --git a/bootstrap/kubeadm/controllers/kubeadmconfig_controller.go b/bootstrap/kubeadm/controllers/kubeadmconfig_controller.go index 07019a84391d..9672f65317cd 100644 --- a/bootstrap/kubeadm/controllers/kubeadmconfig_controller.go +++ b/bootstrap/kubeadm/controllers/kubeadmconfig_controller.go @@ -87,9 +87,7 @@ type Scope struct { } // SetupWithManager sets up the reconciler with the Manager. -func (r *KubeadmConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, option controller.Options) error { - option.Log = mgr.GetLogger().WithValues("KubeadmConfig") - +func (r *KubeadmConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { if r.KubeadmInitLock == nil { r.KubeadmInitLock = locking.NewControlPlaneInitMutex(ctrl.LoggerFrom(ctx).WithName("init-locker"), mgr.GetClient()) } @@ -99,7 +97,7 @@ func (r *KubeadmConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl b := ctrl.NewControllerManagedBy(mgr). For(&bootstrapv1.KubeadmConfig{}). - WithOptions(option). + WithOptions(options). WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). Watches( &source.Kind{Type: &clusterv1.Machine{}}, diff --git a/controllers/cluster_controller.go b/controllers/cluster_controller.go index 8f38d150af51..d8a31f43f19c 100644 --- a/controllers/cluster_controller.go +++ b/controllers/cluster_controller.go @@ -72,8 +72,6 @@ type ClusterReconciler struct { } func (r *ClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { - options.Log = mgr.GetLogger().WithValues("Cluster") - controller, err := ctrl.NewControllerManagedBy(mgr). For(&clusterv1.Cluster{}). Watches( diff --git a/controllers/machine_controller.go b/controllers/machine_controller.go index 32873ead0d8d..12254060feb1 100644 --- a/controllers/machine_controller.go +++ b/controllers/machine_controller.go @@ -85,8 +85,6 @@ type MachineReconciler struct { } func (r *MachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { - options.Log = mgr.GetLogger().WithValues("Machine") - clusterToMachines, err := util.ClusterToObjectsMapper(mgr.GetClient(), &clusterv1.MachineList{}, mgr.GetScheme()) if err != nil { return err diff --git a/controllers/machinedeployment_controller.go b/controllers/machinedeployment_controller.go index ae36fb9ca682..b11e6162ca16 100644 --- a/controllers/machinedeployment_controller.go +++ b/controllers/machinedeployment_controller.go @@ -60,8 +60,6 @@ type MachineDeploymentReconciler struct { } func (r *MachineDeploymentReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { - options.Log = mgr.GetLogger().WithValues("MachineDeployment") - clusterToMachineDeployments, err := util.ClusterToObjectsMapper(mgr.GetClient(), &clusterv1.MachineDeploymentList{}, mgr.GetScheme()) if err != nil { return err diff --git a/controllers/machinehealthcheck_controller.go b/controllers/machinehealthcheck_controller.go index 30e934c10253..699b86729b5c 100644 --- a/controllers/machinehealthcheck_controller.go +++ b/controllers/machinehealthcheck_controller.go @@ -81,8 +81,6 @@ type MachineHealthCheckReconciler struct { } func (r *MachineHealthCheckReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { - options.Log = mgr.GetLogger().WithValues("MachineHealthCheck") - controller, err := ctrl.NewControllerManagedBy(mgr). For(&clusterv1.MachineHealthCheck{}). Watches( diff --git a/controllers/machineset_controller.go b/controllers/machineset_controller.go index 3ff17036eaff..39d043641617 100644 --- a/controllers/machineset_controller.go +++ b/controllers/machineset_controller.go @@ -74,8 +74,6 @@ type MachineSetReconciler struct { } func (r *MachineSetReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { - options.Log = mgr.GetLogger().WithValues("MachineSet") - clusterToMachineSets, err := util.ClusterToObjectsMapper(mgr.GetClient(), &clusterv1.MachineSetList{}, mgr.GetScheme()) if err != nil { return err diff --git a/controllers/remote/cluster_cache_reconciler.go b/controllers/remote/cluster_cache_reconciler.go index 8b84adc6aa0e..c0739da16394 100644 --- a/controllers/remote/cluster_cache_reconciler.go +++ b/controllers/remote/cluster_cache_reconciler.go @@ -40,8 +40,6 @@ type ClusterCacheReconciler struct { } func (r *ClusterCacheReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { - options.Log = mgr.GetLogger().WithValues("ClusterCache") - _, err := ctrl.NewControllerManagedBy(mgr). For(&clusterv1.Cluster{}). WithOptions(options). diff --git a/controllers/topology/controller.go b/controllers/topology/controller.go index 66ddfa67f962..050768f04d6b 100644 --- a/controllers/topology/controller.go +++ b/controllers/topology/controller.go @@ -57,6 +57,7 @@ type ClusterReconciler struct { func (r *ClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { c, err := ctrl.NewControllerManagedBy(mgr). For(&clusterv1.Cluster{}). + Named("cluster/topology"). Watches( &source.Kind{Type: &clusterv1.ClusterClass{}}, handler.EnqueueRequestsFromMapFunc(r.clusterClassToCluster), diff --git a/controlplane/kubeadm/controllers/controller.go b/controlplane/kubeadm/controllers/controller.go index 1fca1e2fb8f6..0e9e69a27e62 100644 --- a/controlplane/kubeadm/controllers/controller.go +++ b/controlplane/kubeadm/controllers/controller.go @@ -72,8 +72,6 @@ type KubeadmControlPlaneReconciler struct { } func (r *KubeadmControlPlaneReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { - options.Log = mgr.GetLogger().WithValues("KubeadmControlPlane") - c, err := ctrl.NewControllerManagedBy(mgr). For(&controlplanev1.KubeadmControlPlane{}). Owns(&clusterv1.Machine{}). diff --git a/exp/addons/controllers/clusterresourceset_controller.go b/exp/addons/controllers/clusterresourceset_controller.go index 8d5f4994c587..7b395c8e69f1 100644 --- a/exp/addons/controllers/clusterresourceset_controller.go +++ b/exp/addons/controllers/clusterresourceset_controller.go @@ -67,8 +67,6 @@ type ClusterResourceSetReconciler struct { } func (r *ClusterResourceSetReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { - options.Log = mgr.GetLogger().WithValues("ClusterResourceSet") - err := ctrl.NewControllerManagedBy(mgr). For(&addonsv1.ClusterResourceSet{}). Watches( diff --git a/exp/addons/controllers/clusterresourcesetbinding_controller.go b/exp/addons/controllers/clusterresourcesetbinding_controller.go index 88a214c35012..05f7c653f3cf 100644 --- a/exp/addons/controllers/clusterresourcesetbinding_controller.go +++ b/exp/addons/controllers/clusterresourcesetbinding_controller.go @@ -42,8 +42,6 @@ type ClusterResourceSetBindingReconciler struct { } func (r *ClusterResourceSetBindingReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { - options.Log = mgr.GetLogger().WithValues("ClusterResourceSetBinding") - _, err := ctrl.NewControllerManagedBy(mgr). For(&addonsv1.ClusterResourceSetBinding{}). Watches( diff --git a/exp/controllers/machinepool_controller.go b/exp/controllers/machinepool_controller.go index a913303dc334..5099c99f507e 100644 --- a/exp/controllers/machinepool_controller.go +++ b/exp/controllers/machinepool_controller.go @@ -66,8 +66,6 @@ type MachinePoolReconciler struct { } func (r *MachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { - options.Log = mgr.GetLogger().WithValues("MachinePool") - clusterToMachinePools, err := util.ClusterToObjectsMapper(mgr.GetClient(), &expv1.MachinePoolList{}, mgr.GetScheme()) if err != nil { return err diff --git a/test/infrastructure/docker/controllers/dockercluster_controller.go b/test/infrastructure/docker/controllers/dockercluster_controller.go index c823905dedf0..c9e8662cea2c 100644 --- a/test/infrastructure/docker/controllers/dockercluster_controller.go +++ b/test/infrastructure/docker/controllers/dockercluster_controller.go @@ -189,9 +189,9 @@ func (r *DockerClusterReconciler) reconcileDelete(ctx context.Context, dockerClu // SetupWithManager will add watches for this controller. func (r *DockerClusterReconciler) SetupWithManager(mgr ctrl.Manager, options controller.Options) error { - options.Log = mgr.GetLogger().WithValues("DockerCluster") c, err := ctrl.NewControllerManagedBy(mgr). For(&infrav1.DockerCluster{}). + WithOptions(options). WithEventFilter(predicates.ResourceNotPaused(r.Log)). Build(r) if err != nil { diff --git a/test/infrastructure/docker/controllers/dockermachine_controller.go b/test/infrastructure/docker/controllers/dockermachine_controller.go index 56a785f5057b..bb50bcdcc1a2 100644 --- a/test/infrastructure/docker/controllers/dockermachine_controller.go +++ b/test/infrastructure/docker/controllers/dockermachine_controller.go @@ -360,8 +360,6 @@ func (r *DockerMachineReconciler) reconcileDelete(ctx context.Context, machine * // SetupWithManager will add watches for this controller. func (r *DockerMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { - options.Log = mgr.GetLogger().WithValues("DockerMachine") - clusterToDockerMachines, err := util.ClusterToObjectsMapper(mgr.GetClient(), &infrav1.DockerMachineList{}, mgr.GetScheme()) if err != nil { return err diff --git a/test/infrastructure/docker/exp/controllers/dockermachinepool_controller.go b/test/infrastructure/docker/exp/controllers/dockermachinepool_controller.go index ce95b970e893..fb94c55f1ee4 100644 --- a/test/infrastructure/docker/exp/controllers/dockermachinepool_controller.go +++ b/test/infrastructure/docker/exp/controllers/dockermachinepool_controller.go @@ -56,7 +56,6 @@ type DockerMachinePoolReconciler struct { func (r *DockerMachinePoolReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.Result, rerr error) { log := ctrl.LoggerFrom(ctx) - // Fetch the DockerMachinePool instance. dockerMachinePool := &infrav1exp.DockerMachinePool{} if err := r.Client.Get(ctx, req.NamespacedName, dockerMachinePool); err != nil { @@ -125,8 +124,6 @@ func (r *DockerMachinePoolReconciler) Reconcile(ctx context.Context, req ctrl.Re // SetupWithManager will add watches for this controller. func (r *DockerMachinePoolReconciler) SetupWithManager(mgr ctrl.Manager, options controller.Options) error { - options.Log = mgr.GetLogger().WithValues("DockerMachinePool") - clusterToDockerMachinePools, err := util.ClusterToObjectsMapper(mgr.GetClient(), &infrav1exp.DockerMachinePoolList{}, mgr.GetScheme()) if err != nil { return err