-
Notifications
You must be signed in to change notification settings - Fork 1k
add dependency policy events #6795
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
base: master
Are you sure you want to change the base?
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 | ||||
---|---|---|---|---|---|---|
|
@@ -588,12 +588,22 @@ func (d *DependenciesDistributor) createOrUpdateAttachedBinding(attachedBinding | |||||
// If the spec.Placement is nil, this means that existBinding is generated by the dependency mechanism. | ||||||
// If the spec.Placement is not nil, then it must be generated by PropagationPolicy. | ||||||
if existBinding.Spec.Placement == nil { | ||||||
// dependency-generated RB: take values from the attached binding | ||||||
existBinding.Spec.ConflictResolution = attachedBinding.Spec.ConflictResolution | ||||||
existBinding.Spec.PreserveResourcesOnDeletion = attachedBinding.Spec.PreserveResourcesOnDeletion | ||||||
} else { | ||||||
// explicit RB: do not override conflict-related fields via dependency path | ||||||
if attachedBinding.Spec.PreserveResourcesOnDeletion != nil || attachedBinding.Spec.ConflictResolution != "" { | ||||||
// notify that dependency path settings are ignored due to explicit policy ownership | ||||||
d.EventRecorder.Eventf(existBinding, corev1.EventTypeWarning, events.EventReasonDependencyOverriddenByExplicitPolicy, | ||||||
"Ignore dependency settings for %s/%s because it is governed by explicit policy.", existBinding.Namespace, existBinding.Name) | ||||||
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. The error message format uses string formatting with %s placeholders but the message text says "Ignore" which is grammatically awkward. Consider changing to "Ignoring dependency settings for %s/%s because it is governed by explicit policy."
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
} | ||||||
} | ||||||
|
||||||
// Always merge relationship and labels | ||||||
existBinding.Spec.RequiredBy = mergeBindingSnapshot(existBinding.Spec.RequiredBy, attachedBinding.Spec.RequiredBy) | ||||||
existBinding.Labels = util.DedupeAndMergeLabels(existBinding.Labels, attachedBinding.Labels) | ||||||
existBinding.Spec.Resource = attachedBinding.Spec.Resource | ||||||
existBinding.Spec.PreserveResourcesOnDeletion = attachedBinding.Spec.PreserveResourcesOnDeletion | ||||||
|
||||||
if err := d.Client.Update(context.TODO(), existBinding); err != nil { | ||||||
klog.Errorf("Failed to update resourceBinding(%s): %v", bindingKey, err) | ||||||
|
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.
The current condition for triggering a warning event,
attachedBinding.Spec.ConflictResolution != ""
, will always be true becauseConflictResolution
is a required field with a default value of"Abort"
. This will cause an event to be logged on every reconciliation for every dependency with an explicit policy, leading to excessive and noisy event logs.A better approach is to check if the values from the dependency path (
attachedBinding
) actually differ from what's already on the explicitResourceBinding
(existBinding
). This ensures that a warning is only emitted when a meaningful configuration difference is being ignored.