From ae5135f7fb065cd7ce2c33500738204a33bc73f1 Mon Sep 17 00:00:00 2001 From: Andy Goldstein Date: Wed, 10 May 2023 15:48:33 -0400 Subject: [PATCH] cache: only enqueue ClusterRoleBindings for the right logical cluster Signed-off-by: Andy Goldstein --- .../labelclusterrolebinding_controller.go | 6 +++--- .../replicateclusterrolebinding_controller.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/reconciler/cache/labelclusterrolebindings/labelclusterrolebinding_controller.go b/pkg/reconciler/cache/labelclusterrolebindings/labelclusterrolebinding_controller.go index 238313c1bbc..6b635cdd472 100644 --- a/pkg/reconciler/cache/labelclusterrolebindings/labelclusterrolebinding_controller.go +++ b/pkg/reconciler/cache/labelclusterrolebindings/labelclusterrolebinding_controller.go @@ -48,7 +48,7 @@ import ( type Controller interface { Start(ctx context.Context, numThreads int) - EnqueueClusterRoleBindings(values ...interface{}) + EnqueueClusterRoleBindings(clusterName logicalcluster.Name, values ...interface{}) } // NewController returns a new controller for labelling ClusterRoleBinding that should be replicated. @@ -144,8 +144,8 @@ type controller struct { commit func(ctx context.Context, new, old *rbacv1.ClusterRoleBinding) error } -func (c *controller) EnqueueClusterRoleBindings(values ...interface{}) { - clusterRoleBindings, err := c.clusterRoleBindingLister.List(labels.Everything()) +func (c *controller) EnqueueClusterRoleBindings(clusterName logicalcluster.Name, values ...interface{}) { + clusterRoleBindings, err := c.clusterRoleBindingLister.Cluster(clusterName).List(labels.Everything()) if err != nil { runtime.HandleError(err) return diff --git a/pkg/reconciler/core/replicateclusterrolebinding/replicateclusterrolebinding_controller.go b/pkg/reconciler/core/replicateclusterrolebinding/replicateclusterrolebinding_controller.go index e156fb8c0f3..0e2665af3a6 100644 --- a/pkg/reconciler/core/replicateclusterrolebinding/replicateclusterrolebinding_controller.go +++ b/pkg/reconciler/core/replicateclusterrolebinding/replicateclusterrolebinding_controller.go @@ -66,7 +66,7 @@ func NewController( Handler: cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { cluster := obj.(*corev1alpha1.LogicalCluster) - c.EnqueueClusterRoleBindings("reason", "LogicalCluster added", "logicalcluster", logicalcluster.From(cluster).String()) + c.EnqueueClusterRoleBindings(logicalcluster.From(cluster), "reason", "LogicalCluster added", "logicalcluster", logicalcluster.From(cluster).String()) }, UpdateFunc: func(old, obj interface{}) { oldCluster, ok := old.(*corev1alpha1.LogicalCluster) @@ -78,7 +78,7 @@ func NewController( return } if (oldCluster.Annotations[core.ReplicateAnnotationKey] == "") != (newCluster.Annotations[core.ReplicateAnnotationKey] == "") { - c.EnqueueClusterRoleBindings("reason", "LogicalCluster changed replication status", "logicalcluster", logicalcluster.From(newCluster).String()) + c.EnqueueClusterRoleBindings(logicalcluster.From(newCluster), "reason", "LogicalCluster changed replication status", "logicalcluster", logicalcluster.From(newCluster).String()) } }, },