Skip to content

Commit abfdd0f

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 abfdd0f

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

pkg/controller/operators/catalog/operator.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import (
4242
"k8s.io/client-go/util/workqueue"
4343

4444
"github.com/operator-framework/api/pkg/operators/reference"
45+
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
4546
"github.com/operator-framework/api/pkg/operators/v1alpha1"
4647
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
4748
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/informers/externalversions"
@@ -260,7 +261,19 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
260261

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

@@ -1086,6 +1099,20 @@ func (o *Operator) syncSubscriptions(obj interface{}) error {
10861099
return nil
10871100
}
10881101

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

0 commit comments

Comments
 (0)