Skip to content

Commit

Permalink
Merge pull request #2959 from sttts/sttts-replicate-clusterrolebindings
Browse files Browse the repository at this point in the history
🐛 cache: only enqueue ClusterRoleBindings for the right logical cluster
  • Loading branch information
openshift-merge-robot committed Jun 3, 2023
2 parents 20aa5f1 + ae5135f commit 7f7ab89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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())
}
},
},
Expand Down

0 comments on commit 7f7ab89

Please sign in to comment.