Skip to content

Commit c995b5e

Browse files
committed
operator: Add OperatorGroup queueinformer
Add a queueinformer for OperatorGroups since they are now an input to resolution via the global catalog exclusion annotation. Namespace resolution will be triggered on changes to an OperatorGroup, in case the value provided on that annotation by the user changes. Signed-off-by: Daniel Sover <[email protected]>
1 parent 78efbbf commit c995b5e

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

Diff for: pkg/controller/operators/catalog/operator.go

+29-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"sync"
1212
"time"
1313

14+
v1 "github.com/operator-framework/api/pkg/operators/v1"
15+
1416
errorwrap "github.com/pkg/errors"
1517
"github.com/sirupsen/logrus"
1618
"google.golang.org/grpc/connectivity"
@@ -260,7 +262,19 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
260262

261263
operatorGroupInformer := crInformerFactory.Operators().V1().OperatorGroups()
262264
op.lister.OperatorsV1().RegisterOperatorGroupLister(metav1.NamespaceAll, operatorGroupInformer.Lister())
263-
if err := op.RegisterInformer(operatorGroupInformer.Informer()); err != nil {
265+
ogQueue := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "ogs")
266+
op.ogQueueSet.Set(metav1.NamespaceAll, ogQueue)
267+
operatorGroupQueueInformer, err := queueinformer.NewQueueInformer(
268+
ctx,
269+
queueinformer.WithLogger(op.logger),
270+
queueinformer.WithQueue(ogQueue),
271+
queueinformer.WithInformer(operatorGroupInformer.Informer()),
272+
queueinformer.WithSyncer(queueinformer.LegacySyncHandler(op.syncOperatorGroups).ToSyncer()),
273+
)
274+
if err != nil {
275+
return nil, err
276+
}
277+
if err := op.RegisterQueueInformer(operatorGroupQueueInformer); err != nil {
264278
return nil, err
265279
}
266280

@@ -1086,6 +1100,20 @@ func (o *Operator) syncSubscriptions(obj interface{}) error {
10861100
return nil
10871101
}
10881102

1103+
// syncOperatorGroups requeues the namespace resolution queue on changes to an operatorgroup
1104+
// This is because the operatorgroup is now an input to resolution via the global catalog exclusion annotation
1105+
func (o *Operator) syncOperatorGroups(obj interface{}) error {
1106+
og, ok := obj.(*v1.OperatorGroup)
1107+
if !ok {
1108+
o.logger.Debugf("wrong type: %#v", obj)
1109+
return fmt.Errorf("casting OperatorGroup failed")
1110+
}
1111+
1112+
o.nsResolveQueue.Add(og.GetNamespace())
1113+
1114+
return nil
1115+
}
1116+
10891117
func (o *Operator) nothingToUpdate(logger *logrus.Entry, sub *v1alpha1.Subscription) bool {
10901118
if sub.Status.InstallPlanRef != nil && sub.Status.State == v1alpha1.SubscriptionStateUpgradePending {
10911119
logger.Debugf("skipping update: installplan already created")

0 commit comments

Comments
 (0)