Skip to content

Commit 8c2f06c

Browse files
[Fix] Fix constant reconciles due to Catalog
Due to the polling feature in the Catalog, the `lastPolledInterval` in the Catalog's status gets updated. Because of this there is a reconcile is trigrred every time the catalog is polled, even though there is no change in the resolved image ref SHA. This causes unnecessary continuous reconciles in the CE. To overcome this, a Predicate is added to accept update events only when there is a change in Resolved reference. Signed-off-by: Varsha Prasad Narsing <[email protected]>
1 parent 79d64e8 commit 8c2f06c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

internal/controllers/clusterextension_controller.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ import (
3232
"k8s.io/utils/ptr"
3333
ctrl "sigs.k8s.io/controller-runtime"
3434
"sigs.k8s.io/controller-runtime/pkg/client"
35+
"sigs.k8s.io/controller-runtime/pkg/event"
3536
"sigs.k8s.io/controller-runtime/pkg/handler"
3637
"sigs.k8s.io/controller-runtime/pkg/log"
38+
"sigs.k8s.io/controller-runtime/pkg/predicate"
3739
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3840

41+
"github.com/operator-framework/catalogd/api/core/v1alpha1"
3942
catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
4043
"github.com/operator-framework/deppy/pkg/deppy"
4144
"github.com/operator-framework/deppy/pkg/deppy/solver"
@@ -409,6 +412,17 @@ func (r *ClusterExtensionReconciler) SetupWithManager(mgr ctrl.Manager) error {
409412
For(&ocv1alpha1.ClusterExtension{}).
410413
Watches(&catalogd.Catalog{},
411414
handler.EnqueueRequestsFromMapFunc(clusterExtensionRequestsForCatalog(mgr.GetClient(), mgr.GetLogger()))).
415+
WithEventFilter(predicate.Funcs{
416+
UpdateFunc: func(ue event.UpdateEvent) bool {
417+
oldObject, isOldCatalog := ue.ObjectOld.(*v1alpha1.Catalog)
418+
newObject, isNewCatalog := ue.ObjectNew.(*v1alpha1.Catalog)
419+
420+
if !isOldCatalog || !isNewCatalog {
421+
return true
422+
}
423+
return oldObject.Status.ResolvedSource.Image.Ref != newObject.Status.ResolvedSource.Image.Ref
424+
},
425+
}).
412426
Owns(&rukpakv1alpha2.BundleDeployment{}).
413427
Complete(r)
414428

0 commit comments

Comments
 (0)