Skip to content

Commit 1544404

Browse files
committed
removing catalog state check for operator reconcile
Signed-off-by: Ankita Thomas <[email protected]>
1 parent 82a834a commit 1544404

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

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.2.0
@@ -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

internal/controllers/operator_controller.go

Lines changed: 28 additions & 5 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,14 +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

42-
"github.com/operator-framework/operator-controller/internal/controllers/validators"
4343
operatorsv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
44+
"github.com/operator-framework/operator-controller/internal/controllers/validators"
4445
"github.com/operator-framework/operator-controller/internal/resolution"
4546
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/bundles_and_dependencies"
4647
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/entity"
@@ -293,8 +294,7 @@ func (r *OperatorReconciler) SetupWithManager(mgr ctrl.Manager) error {
293294
err := ctrl.NewControllerManagedBy(mgr).
294295
For(&operatorsv1alpha1.Operator{}).
295296
Watches(source.NewKindWithCache(&catalogd.CatalogSource{}, mgr.GetCache()),
296-
handler.EnqueueRequestsFromMapFunc(operatorRequestsForCatalog(context.TODO(), mgr.GetClient(), mgr.GetLogger())),
297-
builder.WithPredicates(newCatalogReadyTransitionPredicate())).
297+
handler.EnqueueRequestsFromMapFunc(operatorRequestsForCatalog(context.TODO(), mgr.GetClient(), mgr.GetLogger()))).
298298
Owns(&rukpakv1alpha1.BundleDeployment{}).
299299
Complete(r)
300300

@@ -430,3 +430,26 @@ func setInstalledStatusConditionUnknown(conditions *[]metav1.Condition, message
430430
ObservedGeneration: generation,
431431
})
432432
}
433+
434+
// Generate reconcile requests for all operators affected by a catalog change
435+
func operatorRequestsForCatalog(ctx context.Context, c client.Reader, logger logr.Logger) handler.MapFunc {
436+
return func(object client.Object) []reconcile.Request {
437+
// no way of associating an operator to a catalog so create reconcile requests for everything
438+
operators := operatorv1.OperatorList{}
439+
err := c.List(ctx, &operators)
440+
if err != nil {
441+
logger.Error(err, "unable to enqueue operators for catalog reconcile")
442+
return nil
443+
}
444+
var requests []reconcile.Request
445+
for _, op := range operators.Items {
446+
requests = append(requests, reconcile.Request{
447+
NamespacedName: types.NamespacedName{
448+
Namespace: op.GetNamespace(),
449+
Name: op.GetName(),
450+
},
451+
})
452+
}
453+
return requests
454+
}
455+
}

0 commit comments

Comments
 (0)