diff --git a/bootstrap/kubeadm/controllers/alias.go b/bootstrap/kubeadm/controllers/alias.go index 652e195194e3..9b8df466a084 100644 --- a/bootstrap/kubeadm/controllers/alias.go +++ b/bootstrap/kubeadm/controllers/alias.go @@ -44,8 +44,8 @@ type KubeadmConfigReconciler struct { Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher // TokenTTL is the amount of time a bootstrap token (and therefore a KubeadmConfig) will be valid. TokenTTL time.Duration @@ -54,10 +54,10 @@ type KubeadmConfigReconciler struct { // SetupWithManager sets up the reconciler with the Manager. func (r *KubeadmConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { return (&kubeadmbootstrapcontrollers.KubeadmConfigReconciler{ - Client: r.Client, - SecretCachingClient: r.SecretCachingClient, - Tracker: r.Tracker, - WatchFilterPredicate: r.WatchFilterPredicate, - TokenTTL: r.TokenTTL, + Client: r.Client, + SecretCachingClient: r.SecretCachingClient, + Tracker: r.Tracker, + WatchFilterValue: r.WatchFilterValue, + TokenTTL: r.TokenTTL, }).SetupWithManager(ctx, mgr, options) } diff --git a/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller.go b/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller.go index e3699bf38f4c..e7ed9d4e432a 100644 --- a/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller.go +++ b/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller.go @@ -81,8 +81,8 @@ type KubeadmConfigReconciler struct { Tracker *remote.ClusterCacheTracker KubeadmInitLock InitLocker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher // TokenTTL is the amount of time a bootstrap token (and therefore a KubeadmConfig) will be valid. TokenTTL time.Duration @@ -111,7 +111,7 @@ func (r *KubeadmConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl Watches( &clusterv1.Machine{}, handler.EnqueueRequestsFromMapFunc(r.MachineToBootstrapMapFunc), - ).WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate)) + ).WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)) if feature.Gates.Enabled(feature.MachinePool) { b = b.Watches( @@ -126,7 +126,7 @@ func (r *KubeadmConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl builder.WithPredicates( predicates.All(ctrl.LoggerFrom(ctx), predicates.ClusterUnpausedAndInfrastructureReady(ctrl.LoggerFrom(ctx)), - predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate), + predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue), ), ), ) diff --git a/bootstrap/kubeadm/main.go b/bootstrap/kubeadm/main.go index d35fe55aa353..3775a498cd9d 100644 --- a/bootstrap/kubeadm/main.go +++ b/bootstrap/kubeadm/main.go @@ -318,20 +318,20 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { } if err := (&remote.ClusterCacheReconciler{ - Client: mgr.GetClient(), - Tracker: tracker, - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + Tracker: tracker, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(clusterConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "ClusterCacheReconciler") os.Exit(1) } if err := (&kubeadmbootstrapcontrollers.KubeadmConfigReconciler{ - Client: mgr.GetClient(), - SecretCachingClient: secretCachingClient, - Tracker: tracker, - WatchFilterPredicate: labelSelector, - TokenTTL: tokenTTL, + Client: mgr.GetClient(), + SecretCachingClient: secretCachingClient, + Tracker: tracker, + WatchFilterValue: labelSelector, + TokenTTL: tokenTTL, }).SetupWithManager(ctx, mgr, concurrency(kubeadmConfigConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "KubeadmConfig") os.Exit(1) diff --git a/controllers/alias.go b/controllers/alias.go index 1320571d8949..6bccff843a73 100644 --- a/controllers/alias.go +++ b/controllers/alias.go @@ -47,8 +47,8 @@ type ClusterReconciler struct { UnstructuredCachingClient client.Client APIReader client.Reader - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } func (r *ClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { @@ -56,7 +56,7 @@ func (r *ClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manag Client: r.Client, UnstructuredCachingClient: r.UnstructuredCachingClient, APIReader: r.APIReader, - WatchFilterPredicate: r.WatchFilterPredicate, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } @@ -67,8 +67,8 @@ type MachineReconciler struct { APIReader client.Reader Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher // NodeDrainClientTimeout timeout of the client used for draining nodes. NodeDrainClientTimeout time.Duration @@ -80,7 +80,7 @@ func (r *MachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manag UnstructuredCachingClient: r.UnstructuredCachingClient, APIReader: r.APIReader, Tracker: r.Tracker, - WatchFilterPredicate: r.WatchFilterPredicate, + WatchFilterValue: r.WatchFilterValue, NodeDrainClientTimeout: r.NodeDrainClientTimeout, }).SetupWithManager(ctx, mgr, options) } @@ -92,8 +92,8 @@ type MachineSetReconciler struct { APIReader client.Reader Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } func (r *MachineSetReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { @@ -102,7 +102,7 @@ func (r *MachineSetReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma UnstructuredCachingClient: r.UnstructuredCachingClient, APIReader: r.APIReader, Tracker: r.Tracker, - WatchFilterPredicate: r.WatchFilterPredicate, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } @@ -112,8 +112,8 @@ type MachineDeploymentReconciler struct { UnstructuredCachingClient client.Client APIReader client.Reader - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } func (r *MachineDeploymentReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { @@ -121,7 +121,7 @@ func (r *MachineDeploymentReconciler) SetupWithManager(ctx context.Context, mgr Client: r.Client, UnstructuredCachingClient: r.UnstructuredCachingClient, APIReader: r.APIReader, - WatchFilterPredicate: r.WatchFilterPredicate, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } @@ -130,15 +130,15 @@ type MachineHealthCheckReconciler struct { Client client.Client Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } func (r *MachineHealthCheckReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { return (&machinehealthcheckcontroller.Reconciler{ - Client: r.Client, - Tracker: r.Tracker, - WatchFilterPredicate: r.WatchFilterPredicate, + Client: r.Client, + Tracker: r.Tracker, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } @@ -151,8 +151,8 @@ type ClusterTopologyReconciler struct { RuntimeClient runtimeclient.Client - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher // UnstructuredCachingClient provides a client that forces caching of unstructured objects, // thus allowing to optimize reads for templates or provider specific objects in a managed topology. @@ -165,7 +165,7 @@ func (r *ClusterTopologyReconciler) SetupWithManager(ctx context.Context, mgr ct APIReader: r.APIReader, RuntimeClient: r.RuntimeClient, UnstructuredCachingClient: r.UnstructuredCachingClient, - WatchFilterPredicate: r.WatchFilterPredicate, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } @@ -177,15 +177,15 @@ type MachineDeploymentTopologyReconciler struct { Client client.Client // APIReader is used to list MachineSets directly via the API server to avoid // race conditions caused by an outdated cache. - APIReader client.Reader - WatchFilterPredicate predicates.LabelMatcher + APIReader client.Reader + WatchFilterValue predicates.LabelMatcher } func (r *MachineDeploymentTopologyReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { return (&machinedeploymenttopologycontroller.Reconciler{ - Client: r.Client, - APIReader: r.APIReader, - WatchFilterPredicate: r.WatchFilterPredicate, + Client: r.Client, + APIReader: r.APIReader, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } @@ -197,15 +197,15 @@ type MachineSetTopologyReconciler struct { Client client.Client // APIReader is used to list MachineSets directly via the API server to avoid // race conditions caused by an outdated cache. - APIReader client.Reader - WatchFilterPredicate predicates.LabelMatcher + APIReader client.Reader + WatchFilterValue predicates.LabelMatcher } func (r *MachineSetTopologyReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { return (&machinesettopologycontroller.Reconciler{ - Client: r.Client, - APIReader: r.APIReader, - WatchFilterPredicate: r.WatchFilterPredicate, + Client: r.Client, + APIReader: r.APIReader, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } @@ -217,8 +217,8 @@ type ClusterClassReconciler struct { // RuntimeClient is a client for calling runtime extensions. RuntimeClient runtimeclient.Client - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher // UnstructuredCachingClient provides a client that forces caching of unstructured objects, // thus allowing to optimize reads for templates or provider specific objects. @@ -231,6 +231,6 @@ func (r *ClusterClassReconciler) SetupWithManager(ctx context.Context, mgr ctrl. APIReader: r.APIReader, RuntimeClient: r.RuntimeClient, UnstructuredCachingClient: r.UnstructuredCachingClient, - WatchFilterPredicate: r.WatchFilterPredicate, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } diff --git a/controllers/remote/cluster_cache_reconciler.go b/controllers/remote/cluster_cache_reconciler.go index 1e5ce6c891ad..a49dd6ef6d5f 100644 --- a/controllers/remote/cluster_cache_reconciler.go +++ b/controllers/remote/cluster_cache_reconciler.go @@ -36,8 +36,8 @@ type ClusterCacheReconciler struct { Client client.Client Tracker *ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } func (r *ClusterCacheReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { @@ -45,7 +45,7 @@ func (r *ClusterCacheReconciler) SetupWithManager(ctx context.Context, mgr ctrl. Named("remote/clustercache"). For(&clusterv1.Cluster{}). WithOptions(options). - WithEventFilter(predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate)). + WithEventFilter(predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). Complete(r) if err != nil { diff --git a/controlplane/kubeadm/controllers/alias.go b/controlplane/kubeadm/controllers/alias.go index ee60237063f7..b5be5e5b6de8 100644 --- a/controlplane/kubeadm/controllers/alias.go +++ b/controlplane/kubeadm/controllers/alias.go @@ -38,18 +38,18 @@ type KubeadmControlPlaneReconciler struct { EtcdDialTimeout time.Duration EtcdCallTimeout time.Duration - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } // SetupWithManager sets up the reconciler with the Manager. func (r *KubeadmControlPlaneReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { return (&kubeadmcontrolplanecontrollers.KubeadmControlPlaneReconciler{ - Client: r.Client, - SecretCachingClient: r.SecretCachingClient, - Tracker: r.Tracker, - EtcdDialTimeout: r.EtcdDialTimeout, - EtcdCallTimeout: r.EtcdCallTimeout, - WatchFilterPredicate: r.WatchFilterPredicate, + Client: r.Client, + SecretCachingClient: r.SecretCachingClient, + Tracker: r.Tracker, + EtcdDialTimeout: r.EtcdDialTimeout, + EtcdCallTimeout: r.EtcdCallTimeout, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } diff --git a/controlplane/kubeadm/internal/controllers/controller.go b/controlplane/kubeadm/internal/controllers/controller.go index 4075a522e0fa..45da6bff2253 100644 --- a/controlplane/kubeadm/internal/controllers/controller.go +++ b/controlplane/kubeadm/internal/controllers/controller.go @@ -80,8 +80,8 @@ type KubeadmControlPlaneReconciler struct { EtcdDialTimeout time.Duration EtcdCallTimeout time.Duration - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher managementCluster internal.ManagementCluster managementClusterUncached internal.ManagementCluster @@ -99,13 +99,13 @@ func (r *KubeadmControlPlaneReconciler) SetupWithManager(ctx context.Context, mg For(&controlplanev1.KubeadmControlPlane{}). Owns(&clusterv1.Machine{}). WithOptions(options). - WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate)). + WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). Watches( &clusterv1.Cluster{}, handler.EnqueueRequestsFromMapFunc(r.ClusterToKubeadmControlPlane), builder.WithPredicates( predicates.All(ctrl.LoggerFrom(ctx), - predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate), + predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue), predicates.ClusterUnpausedAndInfrastructureReady(ctrl.LoggerFrom(ctx)), ), ), diff --git a/controlplane/kubeadm/main.go b/controlplane/kubeadm/main.go index 5c6daa5a57cf..599f7fa65454 100644 --- a/controlplane/kubeadm/main.go +++ b/controlplane/kubeadm/main.go @@ -331,21 +331,21 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { } if err := (&remote.ClusterCacheReconciler{ - Client: mgr.GetClient(), - Tracker: tracker, - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + Tracker: tracker, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(kubeadmControlPlaneConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "ClusterCacheReconciler") os.Exit(1) } if err := (&kubeadmcontrolplanecontrollers.KubeadmControlPlaneReconciler{ - Client: mgr.GetClient(), - SecretCachingClient: secretCachingClient, - Tracker: tracker, - WatchFilterPredicate: labelSelector, - EtcdDialTimeout: etcdDialTimeout, - EtcdCallTimeout: etcdCallTimeout, + Client: mgr.GetClient(), + SecretCachingClient: secretCachingClient, + Tracker: tracker, + WatchFilterValue: labelSelector, + EtcdDialTimeout: etcdDialTimeout, + EtcdCallTimeout: etcdCallTimeout, }).SetupWithManager(ctx, mgr, concurrency(kubeadmControlPlaneConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "KubeadmControlPlane") os.Exit(1) diff --git a/exp/addons/controllers/alias.go b/exp/addons/controllers/alias.go index d5affc8b26ad..9accba848578 100644 --- a/exp/addons/controllers/alias.go +++ b/exp/addons/controllers/alias.go @@ -33,15 +33,15 @@ type ClusterResourceSetReconciler struct { Client client.Client Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } func (r *ClusterResourceSetReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { return (&clusterresourcesets.ClusterResourceSetReconciler{ - Client: r.Client, - Tracker: r.Tracker, - WatchFilterPredicate: r.WatchFilterPredicate, + Client: r.Client, + Tracker: r.Tracker, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } @@ -49,13 +49,13 @@ func (r *ClusterResourceSetReconciler) SetupWithManager(ctx context.Context, mgr type ClusterResourceSetBindingReconciler struct { Client client.Client - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } func (r *ClusterResourceSetBindingReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { return (&clusterresourcesets.ClusterResourceSetBindingReconciler{ - Client: r.Client, - WatchFilterPredicate: r.WatchFilterPredicate, + Client: r.Client, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } diff --git a/exp/addons/internal/controllers/clusterresourceset_controller.go b/exp/addons/internal/controllers/clusterresourceset_controller.go index ac5a6d5e5524..d329d58b21f1 100644 --- a/exp/addons/internal/controllers/clusterresourceset_controller.go +++ b/exp/addons/internal/controllers/clusterresourceset_controller.go @@ -61,8 +61,8 @@ type ClusterResourceSetReconciler struct { Client client.Client Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } func (r *ClusterResourceSetReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { @@ -87,7 +87,7 @@ func (r *ClusterResourceSetReconciler) SetupWithManager(ctx context.Context, mgr ), ). WithOptions(options). - WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate)). + WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). Complete(r) if err != nil { return errors.Wrap(err, "failed setting up with a controller manager") diff --git a/exp/addons/internal/controllers/clusterresourcesetbinding_controller.go b/exp/addons/internal/controllers/clusterresourcesetbinding_controller.go index 344ea082f41d..0432cc2feac6 100644 --- a/exp/addons/internal/controllers/clusterresourcesetbinding_controller.go +++ b/exp/addons/internal/controllers/clusterresourcesetbinding_controller.go @@ -43,8 +43,8 @@ import ( type ClusterResourceSetBindingReconciler struct { Client client.Client - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } func (r *ClusterResourceSetBindingReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { @@ -55,7 +55,7 @@ func (r *ClusterResourceSetBindingReconciler) SetupWithManager(ctx context.Conte handler.EnqueueRequestsFromMapFunc(r.clusterToClusterResourceSetBinding), ). WithOptions(options). - WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate)). + WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). Complete(r) if err != nil { return errors.Wrap(err, "failed setting up with a controller manager") diff --git a/exp/controllers/alias.go b/exp/controllers/alias.go index 34ff33ea1c0e..8f6658061e25 100644 --- a/exp/controllers/alias.go +++ b/exp/controllers/alias.go @@ -34,15 +34,15 @@ type MachinePoolReconciler struct { APIReader client.Reader Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } func (r *MachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { return (&machinepool.MachinePoolReconciler{ - Client: r.Client, - APIReader: r.APIReader, - Tracker: r.Tracker, - WatchFilterPredicate: r.WatchFilterPredicate, + Client: r.Client, + APIReader: r.APIReader, + Tracker: r.Tracker, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } diff --git a/exp/internal/controllers/machinepool_controller.go b/exp/internal/controllers/machinepool_controller.go index db7f621ce51d..05d431c3c69c 100644 --- a/exp/internal/controllers/machinepool_controller.go +++ b/exp/internal/controllers/machinepool_controller.go @@ -65,8 +65,8 @@ type MachinePoolReconciler struct { APIReader client.Reader Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher controller controller.Controller recorder record.EventRecorder @@ -82,7 +82,7 @@ func (r *MachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M c, err := ctrl.NewControllerManagedBy(mgr). For(&expv1.MachinePool{}). WithOptions(options). - WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate)). + WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). Watches( &clusterv1.Cluster{}, handler.EnqueueRequestsFromMapFunc(clusterToMachinePools), @@ -90,7 +90,7 @@ func (r *MachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M builder.WithPredicates( predicates.All(ctrl.LoggerFrom(ctx), predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)), - predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate), + predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue), ), ), ). diff --git a/exp/runtime/controllers/alias.go b/exp/runtime/controllers/alias.go index 77e44b2144af..016c7750a377 100644 --- a/exp/runtime/controllers/alias.go +++ b/exp/runtime/controllers/alias.go @@ -34,15 +34,15 @@ type ExtensionConfigReconciler struct { APIReader client.Reader RuntimeClient runtimeclient.Client - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } func (r *ExtensionConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { return (&runtimecontrollers.Reconciler{ - Client: r.Client, - APIReader: r.APIReader, - RuntimeClient: r.RuntimeClient, - WatchFilterPredicate: r.WatchFilterPredicate, + Client: r.Client, + APIReader: r.APIReader, + RuntimeClient: r.RuntimeClient, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } diff --git a/exp/runtime/internal/controllers/extensionconfig_controller.go b/exp/runtime/internal/controllers/extensionconfig_controller.go index 6601cfade78c..2e68538f7681 100644 --- a/exp/runtime/internal/controllers/extensionconfig_controller.go +++ b/exp/runtime/internal/controllers/extensionconfig_controller.go @@ -55,8 +55,8 @@ type Reconciler struct { Client client.Client APIReader client.Reader RuntimeClient runtimeclient.Client - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { @@ -67,7 +67,7 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt handler.EnqueueRequestsFromMapFunc(r.secretToExtensionConfig), ). WithOptions(options). - WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate)). + WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). Complete(r) if err != nil { return errors.Wrap(err, "failed setting up with a controller manager") diff --git a/internal/controllers/cluster/cluster_controller.go b/internal/controllers/cluster/cluster_controller.go index 300f8e5d7356..1866ac3c7530 100644 --- a/internal/controllers/cluster/cluster_controller.go +++ b/internal/controllers/cluster/cluster_controller.go @@ -69,8 +69,8 @@ type Reconciler struct { UnstructuredCachingClient client.Client APIReader client.Reader - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher recorder record.EventRecorder externalTracker external.ObjectTracker @@ -84,7 +84,7 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt handler.EnqueueRequestsFromMapFunc(r.controlPlaneMachineToCluster), ). WithOptions(options). - WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate)). + WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). Build(r) if err != nil { diff --git a/internal/controllers/clusterclass/clusterclass_controller.go b/internal/controllers/clusterclass/clusterclass_controller.go index 4f656029da17..ce4629d2abe1 100644 --- a/internal/controllers/clusterclass/clusterclass_controller.go +++ b/internal/controllers/clusterclass/clusterclass_controller.go @@ -62,8 +62,8 @@ type Reconciler struct { Client client.Client APIReader client.Reader - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher // RuntimeClient is a client for calling runtime extensions. RuntimeClient runtimeclient.Client @@ -82,7 +82,7 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt &runtimev1.ExtensionConfig{}, handler.EnqueueRequestsFromMapFunc(r.extensionConfigToClusterClass), ). - WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate)). + WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). Complete(r) if err != nil { diff --git a/internal/controllers/machine/machine_controller.go b/internal/controllers/machine/machine_controller.go index a9bb6bdfbe46..465dcc6bb4d5 100644 --- a/internal/controllers/machine/machine_controller.go +++ b/internal/controllers/machine/machine_controller.go @@ -79,8 +79,8 @@ type Reconciler struct { APIReader client.Reader Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher // NodeDrainClientTimeout timeout of the client used for draining nodes. NodeDrainClientTimeout time.Duration @@ -108,7 +108,7 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt c, err := ctrl.NewControllerManagedBy(mgr). For(&clusterv1.Machine{}). WithOptions(options). - WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate)). + WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). Watches( &clusterv1.Cluster{}, handler.EnqueueRequestsFromMapFunc(clusterToMachines), @@ -119,7 +119,7 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)), predicates.ClusterControlPlaneInitialized(ctrl.LoggerFrom(ctx)), ), - predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate), + predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue), ), )). Build(r) diff --git a/internal/controllers/machinedeployment/machinedeployment_controller.go b/internal/controllers/machinedeployment/machinedeployment_controller.go index 32b37ad2b098..cdc77634be4a 100644 --- a/internal/controllers/machinedeployment/machinedeployment_controller.go +++ b/internal/controllers/machinedeployment/machinedeployment_controller.go @@ -67,8 +67,8 @@ type Reconciler struct { UnstructuredCachingClient client.Client APIReader client.Reader - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher recorder record.EventRecorder ssaCache ssa.Cache @@ -88,7 +88,7 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt handler.EnqueueRequestsFromMapFunc(r.MachineSetToDeployments), ). WithOptions(options). - WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate)). + WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). Watches( &clusterv1.Cluster{}, handler.EnqueueRequestsFromMapFunc(clusterToMachineDeployments), @@ -96,7 +96,7 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt // TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources? predicates.All(ctrl.LoggerFrom(ctx), predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)), - predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate), + predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue), ), ), ).Complete(r) diff --git a/internal/controllers/machinehealthcheck/machinehealthcheck_controller.go b/internal/controllers/machinehealthcheck/machinehealthcheck_controller.go index cc499176c6a5..3c3f7730b13f 100644 --- a/internal/controllers/machinehealthcheck/machinehealthcheck_controller.go +++ b/internal/controllers/machinehealthcheck/machinehealthcheck_controller.go @@ -77,8 +77,8 @@ type Reconciler struct { Client client.Client Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher controller controller.Controller recorder record.EventRecorder @@ -92,7 +92,7 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt handler.EnqueueRequestsFromMapFunc(r.machineToMachineHealthCheck), ). WithOptions(options). - WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate)). + WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). Watches( &clusterv1.Cluster{}, handler.EnqueueRequestsFromMapFunc(r.clusterToMachineHealthCheck), @@ -100,7 +100,7 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt // TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources? predicates.All(ctrl.LoggerFrom(ctx), predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)), - predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate), + predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue), ), ), ).Build(r) diff --git a/internal/controllers/machineset/machineset_controller.go b/internal/controllers/machineset/machineset_controller.go index 18982c0584a9..480fff31b55a 100644 --- a/internal/controllers/machineset/machineset_controller.go +++ b/internal/controllers/machineset/machineset_controller.go @@ -84,8 +84,8 @@ type Reconciler struct { APIReader client.Reader Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher ssaCache ssa.Cache recorder record.EventRecorder @@ -105,7 +105,7 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt handler.EnqueueRequestsFromMapFunc(r.MachineToMachineSets), ). WithOptions(options). - WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate)). + WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). Watches( &clusterv1.Cluster{}, handler.EnqueueRequestsFromMapFunc(clusterToMachineSets), @@ -113,7 +113,7 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt // TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources? predicates.All(ctrl.LoggerFrom(ctx), predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)), - predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate), + predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue), ), ), ).Complete(r) diff --git a/internal/controllers/topology/cluster/cluster_controller.go b/internal/controllers/topology/cluster/cluster_controller.go index ad1301027506..3edfe5537924 100644 --- a/internal/controllers/topology/cluster/cluster_controller.go +++ b/internal/controllers/topology/cluster/cluster_controller.go @@ -70,8 +70,8 @@ type Reconciler struct { RuntimeClient runtimeclient.Client - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher // UnstructuredCachingClient provides a client that forces caching of unstructured objects, // thus allowing to optimize reads for templates or provider specific objects in a managed topology. @@ -104,7 +104,7 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt builder.WithPredicates(predicates.ResourceIsTopologyOwned(ctrl.LoggerFrom(ctx))), ). WithOptions(options). - WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate)). + WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). Build(r) if err != nil { diff --git a/internal/controllers/topology/machinedeployment/machinedeployment_controller.go b/internal/controllers/topology/machinedeployment/machinedeployment_controller.go index 3e5e3d6d516a..0b3e57227019 100644 --- a/internal/controllers/topology/machinedeployment/machinedeployment_controller.go +++ b/internal/controllers/topology/machinedeployment/machinedeployment_controller.go @@ -50,8 +50,8 @@ type Reconciler struct { Client client.Client // APIReader is used to list MachineSets directly via the API server to avoid // race conditions caused by an outdated cache. - APIReader client.Reader - WatchFilterPredicate predicates.LabelMatcher + APIReader client.Reader + WatchFilterValue predicates.LabelMatcher } func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { @@ -60,7 +60,7 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt Named("topology/machinedeployment"). WithOptions(options). WithEventFilter(predicates.All(ctrl.LoggerFrom(ctx), - predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate), + predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue), predicates.ResourceIsTopologyOwned(ctrl.LoggerFrom(ctx)), )). Complete(r) diff --git a/internal/controllers/topology/machineset/machineset_controller.go b/internal/controllers/topology/machineset/machineset_controller.go index c397b266b74c..4c23c3aa5672 100644 --- a/internal/controllers/topology/machineset/machineset_controller.go +++ b/internal/controllers/topology/machineset/machineset_controller.go @@ -52,8 +52,8 @@ type Reconciler struct { Client client.Client // APIReader is used to list MachineSets directly via the API server to avoid // race conditions caused by an outdated cache. - APIReader client.Reader - WatchFilterPredicate predicates.LabelMatcher + APIReader client.Reader + WatchFilterValue predicates.LabelMatcher } func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { @@ -62,7 +62,7 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt Named("topology/machineset"). WithOptions(options). WithEventFilter(predicates.All(ctrl.LoggerFrom(ctx), - predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterPredicate), + predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue), predicates.ResourceIsTopologyOwned(ctrl.LoggerFrom(ctx)), )). Complete(r) diff --git a/main.go b/main.go index fe9e3284e8c6..f57ea78f0514 100644 --- a/main.go +++ b/main.go @@ -405,9 +405,9 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { } if err := (&remote.ClusterCacheReconciler{ - Client: mgr.GetClient(), - Tracker: tracker, - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + Tracker: tracker, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(clusterConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "ClusterCacheReconciler") os.Exit(1) @@ -441,7 +441,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { APIReader: mgr.GetAPIReader(), RuntimeClient: runtimeClient, UnstructuredCachingClient: unstructuredCachingClient, - WatchFilterPredicate: labelSelector, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(clusterClassConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "ClusterClass") os.Exit(1) @@ -452,25 +452,25 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { APIReader: mgr.GetAPIReader(), RuntimeClient: runtimeClient, UnstructuredCachingClient: unstructuredCachingClient, - WatchFilterPredicate: labelSelector, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(clusterTopologyConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "ClusterTopology") os.Exit(1) } if err := (&controllers.MachineDeploymentTopologyReconciler{ - Client: mgr.GetClient(), - APIReader: mgr.GetAPIReader(), - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + APIReader: mgr.GetAPIReader(), + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, controller.Options{}); err != nil { setupLog.Error(err, "unable to create controller", "controller", "MachineDeploymentTopology") os.Exit(1) } if err := (&controllers.MachineSetTopologyReconciler{ - Client: mgr.GetClient(), - APIReader: mgr.GetAPIReader(), - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + APIReader: mgr.GetAPIReader(), + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, controller.Options{}); err != nil { setupLog.Error(err, "unable to create controller", "controller", "MachineSetTopology") os.Exit(1) @@ -479,10 +479,10 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { if feature.Gates.Enabled(feature.RuntimeSDK) { if err = (&runtimecontrollers.ExtensionConfigReconciler{ - Client: mgr.GetClient(), - APIReader: mgr.GetAPIReader(), - RuntimeClient: runtimeClient, - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + APIReader: mgr.GetAPIReader(), + RuntimeClient: runtimeClient, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(extensionConfigConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "ExtensionConfig") os.Exit(1) @@ -493,7 +493,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { Client: mgr.GetClient(), UnstructuredCachingClient: unstructuredCachingClient, APIReader: mgr.GetAPIReader(), - WatchFilterPredicate: labelSelector, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(clusterConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "Cluster") os.Exit(1) @@ -503,7 +503,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { UnstructuredCachingClient: unstructuredCachingClient, APIReader: mgr.GetAPIReader(), Tracker: tracker, - WatchFilterPredicate: labelSelector, + WatchFilterValue: labelSelector, NodeDrainClientTimeout: nodeDrainClientTimeout, }).SetupWithManager(ctx, mgr, concurrency(machineConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "Machine") @@ -514,7 +514,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { UnstructuredCachingClient: unstructuredCachingClient, APIReader: mgr.GetAPIReader(), Tracker: tracker, - WatchFilterPredicate: labelSelector, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(machineSetConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "MachineSet") os.Exit(1) @@ -523,7 +523,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { Client: mgr.GetClient(), UnstructuredCachingClient: unstructuredCachingClient, APIReader: mgr.GetAPIReader(), - WatchFilterPredicate: labelSelector, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(machineDeploymentConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "MachineDeployment") os.Exit(1) @@ -531,10 +531,10 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { if feature.Gates.Enabled(feature.MachinePool) { if err := (&expcontrollers.MachinePoolReconciler{ - Client: mgr.GetClient(), - APIReader: mgr.GetAPIReader(), - Tracker: tracker, - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + APIReader: mgr.GetAPIReader(), + Tracker: tracker, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(machinePoolConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "MachinePool") os.Exit(1) @@ -543,16 +543,16 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { if feature.Gates.Enabled(feature.ClusterResourceSet) { if err := (&addonscontrollers.ClusterResourceSetReconciler{ - Client: mgr.GetClient(), - Tracker: tracker, - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + Tracker: tracker, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(clusterResourceSetConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "ClusterResourceSet") os.Exit(1) } if err := (&addonscontrollers.ClusterResourceSetBindingReconciler{ - Client: mgr.GetClient(), - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(clusterResourceSetConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "ClusterResourceSetBinding") os.Exit(1) @@ -560,9 +560,9 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { } if err := (&controllers.MachineHealthCheckReconciler{ - Client: mgr.GetClient(), - Tracker: tracker, - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + Tracker: tracker, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(machineHealthCheckConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "MachineHealthCheck") os.Exit(1) diff --git a/test/infrastructure/docker/controllers/alias.go b/test/infrastructure/docker/controllers/alias.go index 4be4614fd0e0..b8b3927edcf6 100644 --- a/test/infrastructure/docker/controllers/alias.go +++ b/test/infrastructure/docker/controllers/alias.go @@ -39,17 +39,17 @@ type DockerMachineReconciler struct { ContainerRuntime container.Runtime Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } // SetupWithManager sets up the reconciler with the Manager. func (r *DockerMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { return (&dockercontrollers.DockerMachineReconciler{ - Client: r.Client, - ContainerRuntime: r.ContainerRuntime, - Tracker: r.Tracker, - WatchFilterPredicate: r.WatchFilterPredicate, + Client: r.Client, + ContainerRuntime: r.ContainerRuntime, + Tracker: r.Tracker, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } @@ -58,15 +58,15 @@ type DockerClusterReconciler struct { Client client.Client ContainerRuntime container.Runtime - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } // SetupWithManager sets up the reconciler with the Manager. func (r *DockerClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { return (&dockercontrollers.DockerClusterReconciler{ - Client: r.Client, - ContainerRuntime: r.ContainerRuntime, - WatchFilterPredicate: r.WatchFilterPredicate, + Client: r.Client, + ContainerRuntime: r.ContainerRuntime, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } diff --git a/test/infrastructure/docker/exp/controllers/alias.go b/test/infrastructure/docker/exp/controllers/alias.go index 86cd5381d2db..9d35507e2255 100644 --- a/test/infrastructure/docker/exp/controllers/alias.go +++ b/test/infrastructure/docker/exp/controllers/alias.go @@ -38,17 +38,17 @@ type DockerMachinePoolReconciler struct { ContainerRuntime container.Runtime Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } // SetupWithManager will add watches for this controller. func (r *DockerMachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { return (&dockermachinepoolcontrollers.DockerMachinePoolReconciler{ - Client: r.Client, - Scheme: r.Scheme, - ContainerRuntime: r.ContainerRuntime, - Tracker: r.Tracker, - WatchFilterPredicate: r.WatchFilterPredicate, + Client: r.Client, + Scheme: r.Scheme, + ContainerRuntime: r.ContainerRuntime, + Tracker: r.Tracker, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } diff --git a/test/infrastructure/docker/exp/internal/controllers/dockermachinepool_controller.go b/test/infrastructure/docker/exp/internal/controllers/dockermachinepool_controller.go index 09f58cdf7a7f..a42905cd345e 100644 --- a/test/infrastructure/docker/exp/internal/controllers/dockermachinepool_controller.go +++ b/test/infrastructure/docker/exp/internal/controllers/dockermachinepool_controller.go @@ -53,8 +53,8 @@ type DockerMachinePoolReconciler struct { ContainerRuntime container.Runtime Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } // +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=dockermachinepools,verbs=get;list;watch;create;update;patch;delete diff --git a/test/infrastructure/docker/internal/controllers/dockercluster_controller.go b/test/infrastructure/docker/internal/controllers/dockercluster_controller.go index 3eb26332fc47..5145ed971a05 100644 --- a/test/infrastructure/docker/internal/controllers/dockercluster_controller.go +++ b/test/infrastructure/docker/internal/controllers/dockercluster_controller.go @@ -45,8 +45,8 @@ type DockerClusterReconciler struct { client.Client ContainerRuntime container.Runtime - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } // +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=dockerclusters,verbs=get;list;watch;create;update;patch;delete diff --git a/test/infrastructure/docker/internal/controllers/dockermachine_controller.go b/test/infrastructure/docker/internal/controllers/dockermachine_controller.go index 60f709e31622..250e1665567c 100644 --- a/test/infrastructure/docker/internal/controllers/dockermachine_controller.go +++ b/test/infrastructure/docker/internal/controllers/dockermachine_controller.go @@ -54,8 +54,8 @@ type DockerMachineReconciler struct { ContainerRuntime container.Runtime Tracker *remote.ClusterCacheTracker - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } // +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=dockermachines,verbs=get;list;watch;create;update;patch;delete diff --git a/test/infrastructure/docker/main.go b/test/infrastructure/docker/main.go index dd88e29b1a8e..0113aa296222 100644 --- a/test/infrastructure/docker/main.go +++ b/test/infrastructure/docker/main.go @@ -325,9 +325,9 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { } if err := (&remote.ClusterCacheReconciler{ - Client: mgr.GetClient(), - Tracker: tracker, - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + Tracker: tracker, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, controller.Options{ MaxConcurrentReconciles: concurrency, }); err != nil { @@ -336,10 +336,10 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { } if err := (&controllers.DockerMachineReconciler{ - Client: mgr.GetClient(), - ContainerRuntime: runtimeClient, - Tracker: tracker, - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + ContainerRuntime: runtimeClient, + Tracker: tracker, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, controller.Options{ MaxConcurrentReconciles: concurrency, }); err != nil { @@ -348,9 +348,9 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { } if err := (&controllers.DockerClusterReconciler{ - Client: mgr.GetClient(), - ContainerRuntime: runtimeClient, - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + ContainerRuntime: runtimeClient, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, controller.Options{}); err != nil { setupLog.Error(err, "unable to create controller", "controller", "DockerCluster") os.Exit(1) @@ -358,10 +358,10 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { if feature.Gates.Enabled(feature.MachinePool) { if err := (&expcontrollers.DockerMachinePoolReconciler{ - Client: mgr.GetClient(), - ContainerRuntime: runtimeClient, - Tracker: tracker, - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + ContainerRuntime: runtimeClient, + Tracker: tracker, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: concurrency}); err != nil { setupLog.Error(err, "unable to create controller", "controller", "DockerMachinePool") os.Exit(1) diff --git a/test/infrastructure/inmemory/controllers/alias.go b/test/infrastructure/inmemory/controllers/alias.go index 4cfe3dff3db9..db9a8b5ce426 100644 --- a/test/infrastructure/inmemory/controllers/alias.go +++ b/test/infrastructure/inmemory/controllers/alias.go @@ -39,17 +39,17 @@ type InMemoryClusterReconciler struct { CloudManager cloud.Manager APIServerMux *server.WorkloadClustersMux // TODO: find a way to use an interface here - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } // SetupWithManager sets up the reconciler with the Manager. func (r *InMemoryClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { return (&inmemorycontrollers.InMemoryClusterReconciler{ - Client: r.Client, - CloudManager: r.CloudManager, - APIServerMux: r.APIServerMux, - WatchFilterPredicate: r.WatchFilterPredicate, + Client: r.Client, + CloudManager: r.CloudManager, + APIServerMux: r.APIServerMux, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } @@ -59,16 +59,16 @@ type InMemoryMachineReconciler struct { CloudManager cloud.Manager APIServerMux *server.WorkloadClustersMux // TODO: find a way to use an interface here - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } // SetupWithManager sets up the reconciler with the Manager. func (r *InMemoryMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { return (&inmemorycontrollers.InMemoryMachineReconciler{ - Client: r.Client, - CloudManager: r.CloudManager, - APIServerMux: r.APIServerMux, - WatchFilterPredicate: r.WatchFilterPredicate, + Client: r.Client, + CloudManager: r.CloudManager, + APIServerMux: r.APIServerMux, + WatchFilterValue: r.WatchFilterValue, }).SetupWithManager(ctx, mgr, options) } diff --git a/test/infrastructure/inmemory/internal/controllers/inmemorycluster_controller.go b/test/infrastructure/inmemory/internal/controllers/inmemorycluster_controller.go index bc38d1aaa1e6..0b336ec36ded 100644 --- a/test/infrastructure/inmemory/internal/controllers/inmemorycluster_controller.go +++ b/test/infrastructure/inmemory/internal/controllers/inmemorycluster_controller.go @@ -46,8 +46,8 @@ type InMemoryClusterReconciler struct { CloudManager cloud.Manager APIServerMux *server.WorkloadClustersMux - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher hotRestartDone bool hotRestartLock sync.RWMutex @@ -210,6 +210,10 @@ func (r *InMemoryClusterReconciler) SetupWithManager(ctx context.Context, mgr ct For(&infrav1.InMemoryCluster{}). WithOptions(options). WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)). +<<<<<<< HEAD +======= + WithEventFilter(predicates.GetExpressionMatcher().Matches(ctrl.LoggerFrom(ctx))). +>>>>>>> 38001904c (Revert to WatchFilterValue) Watches( &clusterv1.Cluster{}, handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("InMemoryCluster"), mgr.GetClient(), &infrav1.InMemoryCluster{})), diff --git a/test/infrastructure/inmemory/internal/controllers/inmemorymachine_controller.go b/test/infrastructure/inmemory/internal/controllers/inmemorymachine_controller.go index 0f96403705ea..db207bbf9dc2 100644 --- a/test/infrastructure/inmemory/internal/controllers/inmemorymachine_controller.go +++ b/test/infrastructure/inmemory/internal/controllers/inmemorymachine_controller.go @@ -64,8 +64,8 @@ type InMemoryMachineReconciler struct { CloudManager cloud.Manager APIServerMux *server.WorkloadClustersMux - // WatchFilterPredicate is the label selector value used to filter events prior to reconciliation. - WatchFilterPredicate predicates.LabelMatcher + // WatchFilterValue is the label selector value used to filter events prior to reconciliation. + WatchFilterValue predicates.LabelMatcher } // +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=inmemorymachines,verbs=get;list;watch;create;update;patch;delete diff --git a/test/infrastructure/inmemory/main.go b/test/infrastructure/inmemory/main.go index 53340eae619c..9c9a5d051921 100644 --- a/test/infrastructure/inmemory/main.go +++ b/test/infrastructure/inmemory/main.go @@ -294,20 +294,20 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { // Setup reconcilers if err := (&controllers.InMemoryClusterReconciler{ - Client: mgr.GetClient(), - CloudManager: cloudMgr, - APIServerMux: apiServerMux, - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + CloudManager: cloudMgr, + APIServerMux: apiServerMux, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(clusterConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "InMemoryCluster") os.Exit(1) } if err := (&controllers.InMemoryMachineReconciler{ - Client: mgr.GetClient(), - CloudManager: cloudMgr, - APIServerMux: apiServerMux, - WatchFilterPredicate: labelSelector, + Client: mgr.GetClient(), + CloudManager: cloudMgr, + APIServerMux: apiServerMux, + WatchFilterValue: labelSelector, }).SetupWithManager(ctx, mgr, concurrency(machineConcurrency)); err != nil { setupLog.Error(err, "unable to create controller", "controller", "InMemoryMachine") os.Exit(1) diff --git a/util/predicates/expression_predicates.go b/util/predicates/expression_predicates.go index 4541e98f8424..1c1502168282 100644 --- a/util/predicates/expression_predicates.go +++ b/util/predicates/expression_predicates.go @@ -22,7 +22,6 @@ import ( "github.com/go-logr/logr" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" - "sigs.k8s.io/controller-runtime/pkg/predicate" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -75,7 +74,7 @@ func InitLabelMatcher(log logr.Logger, labelExpression string) (LabelMatcher, er return matcher, nil } -// Selector returns compiled label selector if it was initialized from expression +// Selector returns compiled label selector if it was initialized from expression. func (m *LabelMatcher) Selector() labels.Selector { return m.selector } diff --git a/util/predicates/suite_test.go b/util/predicates/suite_test.go index ab6b6a8c826f..9235e1f1b3ea 100644 --- a/util/predicates/suite_test.go +++ b/util/predicates/suite_test.go @@ -40,14 +40,14 @@ var ( // Reconciler reconciles a Machine object. type Reconciler struct { - Client client.Client - WatchFilterPredicate LabelMatcher + Client client.Client + WatchFilterValue LabelMatcher } func (r *Reconciler) SetupWithManager(_ context.Context, mgr ctrl.Manager, opts controller.Options) error { return ctrl.NewControllerManagedBy(mgr). For(&clusterv1.Machine{}). - WithEventFilter(r.WatchFilterPredicate.Matches(logger)). + WithEventFilter(r.WatchFilterValue.Matches(logger)). WithOptions(opts). Complete(r) } @@ -71,8 +71,8 @@ func TestMain(m *testing.M) { } setupReconcilers := func(ctx context.Context, mgr ctrl.Manager) { if err := (&Reconciler{ - Client: mgr.GetClient(), - WatchFilterPredicate: matcher, + Client: mgr.GetClient(), + WatchFilterValue: matcher, }).SetupWithManager(ctx, mgr, controller.Options{}); err != nil { panic(fmt.Sprintf("unable to create machine reconciler: %v", err)) }