Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions internal/controller/dataprotectionapplication_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controller
import (
"context"
"os"
"reflect"

"github.com/go-logr/logr"
routev1 "github.com/openshift/api/route/v1"
Expand Down Expand Up @@ -193,6 +194,21 @@ func (l *labelHandler) Update(ctx context.Context, evt event.TypedUpdateEvent[cl
if evt.ObjectNew.GetLabels()[oadpv1alpha1.OadpOperatorLabel] == "" || dpaname == "" {
return
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not to use predicate around line 158 and do the predicate:

return !equality.Semantic.DeepEqual(oldSecret.Data, newSecret.Data) ||
			!equality.Semantic.DeepEqual(oldSecret.StringData, newSecret.StringData) ||
			!equality.Semantic.DeepEqual(oldSecret.Labels, newSecret.Labels)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only want this applied to secret watcher. The change is specific to secret. Doing secret type comparison for every reconcile when its not necessarily a secret event is imo not necessary.

Now if we didn't have labelHandler added to secret watch, perhaps it would be easier to modify existing "global" predicate.

Since we already have labelHandler, I rather scope it to that handler.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The semantic.deepequal is cool..

// For Secrets, check if only metadata changed (e.g., ResourceVersion updates from ESO)
// This prevents unnecessary reconciliations when external-secrets-operator updates metadata
if oldSecret, ok := evt.ObjectOld.(*corev1.Secret); ok {
if newSecret, ok := evt.ObjectNew.(*corev1.Secret); ok {
// Skip reconciliation if data, stringData, and labels haven't changed
// This filters out metadata-only updates (ResourceVersion, ManagedFields, etc.)
if reflect.DeepEqual(oldSecret.Data, newSecret.Data) &&
reflect.DeepEqual(oldSecret.StringData, newSecret.StringData) &&
reflect.DeepEqual(oldSecret.Labels, newSecret.Labels) {
return
}
}
}

q.Add(reconcile.Request{NamespacedName: types.NamespacedName{
Name: dpaname,
Namespace: namespace,
Expand Down
Loading