@@ -20,9 +20,10 @@ import (
20
20
"context"
21
21
"fmt"
22
22
23
+ "github.com/go-logr/logr"
24
+ operatorv1 "github.com/operator-framework/api/pkg/operators/v1"
23
25
catalogd "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1"
24
26
"github.com/operator-framework/deppy/pkg/deppy/solver"
25
- "github.com/operator-framework/operator-controller/controllers/validators"
26
27
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
27
28
"k8s.io/apimachinery/pkg/api/equality"
28
29
apimeta "k8s.io/apimachinery/pkg/api/meta"
@@ -33,12 +34,14 @@ import (
33
34
utilerrors "k8s.io/apimachinery/pkg/util/errors"
34
35
"k8s.io/utils/pointer"
35
36
ctrl "sigs.k8s.io/controller-runtime"
36
- "sigs.k8s.io/controller-runtime/pkg/builder"
37
37
"sigs.k8s.io/controller-runtime/pkg/client"
38
38
"sigs.k8s.io/controller-runtime/pkg/handler"
39
39
"sigs.k8s.io/controller-runtime/pkg/log"
40
+ "sigs.k8s.io/controller-runtime/pkg/reconcile"
40
41
"sigs.k8s.io/controller-runtime/pkg/source"
41
42
43
+ "github.com/operator-framework/operator-controller/controllers/validators"
44
+
42
45
operatorsv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
43
46
"github.com/operator-framework/operator-controller/internal/resolution"
44
47
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/bundles_and_dependencies"
@@ -299,8 +302,7 @@ func (r *OperatorReconciler) SetupWithManager(mgr ctrl.Manager) error {
299
302
err := ctrl .NewControllerManagedBy (mgr ).
300
303
For (& operatorsv1alpha1.Operator {}).
301
304
Watches (source .NewKindWithCache (& catalogd.CatalogSource {}, mgr .GetCache ()),
302
- handler .EnqueueRequestsFromMapFunc (operatorRequestsForCatalog (context .TODO (), mgr .GetClient (), mgr .GetLogger ())),
303
- builder .WithPredicates (newCatalogReadyTransitionPredicate ())).
305
+ handler .EnqueueRequestsFromMapFunc (operatorRequestsForCatalog (context .TODO (), mgr .GetClient (), mgr .GetLogger ()))).
304
306
Owns (& rukpakv1alpha1.BundleDeployment {}).
305
307
Complete (r )
306
308
@@ -407,3 +409,26 @@ func mapBDStatusToReadyCondition(existingBD *rukpakv1alpha1.BundleDeployment, ob
407
409
func isBundleDepStale (bd * rukpakv1alpha1.BundleDeployment ) bool {
408
410
return bd != nil && bd .Status .ObservedGeneration != bd .GetGeneration ()
409
411
}
412
+
413
+ // Generate reconcile requests for all operators affected by a catalog change
414
+ func operatorRequestsForCatalog (ctx context.Context , c client.Reader , logger logr.Logger ) handler.MapFunc {
415
+ return func (object client.Object ) []reconcile.Request {
416
+ // no way of associating an operator to a catalog so create reconcile requests for everything
417
+ operators := operatorv1.OperatorList {}
418
+ err := c .List (ctx , & operators )
419
+ if err != nil {
420
+ logger .Error (err , "unable to enqueue operators for catalog reconcile" )
421
+ return nil
422
+ }
423
+ var requests []reconcile.Request
424
+ for _ , op := range operators .Items {
425
+ requests = append (requests , reconcile.Request {
426
+ NamespacedName : types.NamespacedName {
427
+ Namespace : op .GetNamespace (),
428
+ Name : op .GetName (),
429
+ },
430
+ })
431
+ }
432
+ return requests
433
+ }
434
+ }
0 commit comments