-
Notifications
You must be signed in to change notification settings - Fork 86
fix(controller): prevent NodeAgent restarts from ESO metadata updates #1999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,7 @@ package controller | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "context" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "os" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "reflect" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/go-logr/logr" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| routev1 "github.com/openshift/api/route/v1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -193,6 +194,21 @@ func (l *labelHandler) Update(ctx context.Context, evt event.TypedUpdateEvent[cl | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if evt.ObjectNew.GetLabels()[oadpv1alpha1.OadpOperatorLabel] == "" || dpaname == "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 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) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also check for annotations ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are explicitly avoiding reconcile on annotation changes.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+197
to
+210
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Secret.Type to the comparison; StringData check is ineffective in practice. The metadata-only filter correctly prevents ESO-triggered reconciliations, but:
Apply this diff to add the Type field check: // 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) {
+ reflect.DeepEqual(oldSecret.Labels, newSecret.Labels) &&
+ oldSecret.Type == newSecret.Type {
return
}
}
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| q.Add(reconcile.Request{NamespacedName: types.NamespacedName{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Name: dpaname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Namespace: namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weshayutin although.. do we know if they are changing label every 30 seconds? are we supposed to ignore label changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple notes that I have would be.