Skip to content

Commit 467e627

Browse files
committed
removing catalog state check for operator reconcile
Signed-off-by: Ankita Thomas <[email protected]>
1 parent 9eaf91f commit 467e627

File tree

3 files changed

+30
-120
lines changed

3 files changed

+30
-120
lines changed

controllers/catalog_predicates.go

Lines changed: 0 additions & 115 deletions
This file was deleted.

controllers/operator_controller.go

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ import (
2020
"context"
2121
"fmt"
2222

23+
"github.com/go-logr/logr"
24+
operatorv1 "github.com/operator-framework/api/pkg/operators/v1"
2325
catalogd "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1"
2426
"github.com/operator-framework/deppy/pkg/deppy/solver"
25-
"github.com/operator-framework/operator-controller/controllers/validators"
2627
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
2728
"k8s.io/apimachinery/pkg/api/equality"
2829
apimeta "k8s.io/apimachinery/pkg/api/meta"
@@ -33,12 +34,14 @@ import (
3334
utilerrors "k8s.io/apimachinery/pkg/util/errors"
3435
"k8s.io/utils/pointer"
3536
ctrl "sigs.k8s.io/controller-runtime"
36-
"sigs.k8s.io/controller-runtime/pkg/builder"
3737
"sigs.k8s.io/controller-runtime/pkg/client"
3838
"sigs.k8s.io/controller-runtime/pkg/handler"
3939
"sigs.k8s.io/controller-runtime/pkg/log"
40+
"sigs.k8s.io/controller-runtime/pkg/reconcile"
4041
"sigs.k8s.io/controller-runtime/pkg/source"
4142

43+
"github.com/operator-framework/operator-controller/controllers/validators"
44+
4245
operatorsv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
4346
"github.com/operator-framework/operator-controller/internal/resolution"
4447
"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 {
299302
err := ctrl.NewControllerManagedBy(mgr).
300303
For(&operatorsv1alpha1.Operator{}).
301304
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()))).
304306
Owns(&rukpakv1alpha1.BundleDeployment{}).
305307
Complete(r)
306308

@@ -407,3 +409,26 @@ func mapBDStatusToReadyCondition(existingBD *rukpakv1alpha1.BundleDeployment, ob
407409
func isBundleDepStale(bd *rukpakv1alpha1.BundleDeployment) bool {
408410
return bd != nil && bd.Status.ObservedGeneration != bd.GetGeneration()
409411
}
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+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ go 1.19
44

55
require (
66
github.com/blang/semver/v4 v4.0.0
7-
github.com/go-logr/logr v1.2.3
87
github.com/onsi/ginkgo/v2 v2.8.3
98
github.com/onsi/gomega v1.27.1
109
github.com/operator-framework/catalogd v0.1.3
@@ -27,6 +26,7 @@ require (
2726
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
2827
github.com/fsnotify/fsnotify v1.6.0 // indirect
2928
github.com/go-air/gini v1.0.4 // indirect
29+
github.com/go-logr/logr v1.2.3 // indirect
3030
github.com/go-logr/zapr v1.2.3 // indirect
3131
github.com/go-openapi/jsonpointer v0.19.5 // indirect
3232
github.com/go-openapi/jsonreference v0.20.0 // indirect

0 commit comments

Comments
 (0)