Skip to content

Commit

Permalink
Revert to WatchFilterValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Danil-Grigorev committed Jul 14, 2023
1 parent f133da3 commit e44db26
Show file tree
Hide file tree
Showing 37 changed files with 244 additions and 241 deletions.
14 changes: 7 additions & 7 deletions bootstrap/kubeadm/controllers/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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),
),
),
)
Expand Down
16 changes: 8 additions & 8 deletions bootstrap/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
66 changes: 33 additions & 33 deletions controllers/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ 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 {
return (&clustercontroller.Reconciler{
Client: r.Client,
UnstructuredCachingClient: r.UnstructuredCachingClient,
APIReader: r.APIReader,
WatchFilterPredicate: r.WatchFilterPredicate,
WatchFilterValue: r.WatchFilterValue,
}).SetupWithManager(ctx, mgr, options)
}

Expand All @@ -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
Expand All @@ -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)
}
Expand All @@ -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 {
Expand All @@ -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)
}

Expand All @@ -112,16 +112,16 @@ 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 {
return (&machinedeploymentcontroller.Reconciler{
Client: r.Client,
UnstructuredCachingClient: r.UnstructuredCachingClient,
APIReader: r.APIReader,
WatchFilterPredicate: r.WatchFilterPredicate,
WatchFilterValue: r.WatchFilterValue,
}).SetupWithManager(ctx, mgr, options)
}

Expand All @@ -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)
}

Expand All @@ -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.
Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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.
Expand All @@ -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)
}
6 changes: 3 additions & 3 deletions controllers/remote/cluster_cache_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ 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 {
err := ctrl.NewControllerManagedBy(mgr).
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 {
Expand Down
16 changes: 8 additions & 8 deletions controlplane/kubeadm/controllers/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
8 changes: 4 additions & 4 deletions controlplane/kubeadm/internal/controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)),
),
),
Expand Down
18 changes: 9 additions & 9 deletions controlplane/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit e44db26

Please sign in to comment.