Skip to content

Commit

Permalink
Merge pull request #6053 from whitewindmills/automated-cherry-pick-of…
Browse files Browse the repository at this point in the history
…-#6034-upstream-release-1.10

Automated cherry pick of #6034: fix the attached binding deletion problem
  • Loading branch information
karmada-bot authored Jan 16, 2025
2 parents 6ef2e5c + 9b9204f commit 908c04b
Show file tree
Hide file tree
Showing 2 changed files with 650 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/dependenciesdistributor/dependencies_distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,18 @@ func (d *DependenciesDistributor) createOrUpdateAttachedBinding(attachedBinding
bindingKey := client.ObjectKeyFromObject(attachedBinding)
err := d.Client.Get(context.TODO(), bindingKey, existBinding)
if err == nil {
// If this binding exists and its owner is not the input object, return error and let garbage collector
// delete this binding and try again later. See https://github.com/karmada-io/karmada/issues/6034.
if ownerRef := metav1.GetControllerOfNoCopy(existBinding); ownerRef != nil && ownerRef.UID != attachedBinding.OwnerReferences[0].UID {
return fmt.Errorf("failed to update resourceBinding(%s) due to different owner reference UID, will "+
"try again later after binding is garbage collected, see https://github.com/karmada-io/karmada/issues/6034", bindingKey)
}

// 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 {
existBinding.Spec.ConflictResolution = attachedBinding.Spec.ConflictResolution
}
existBinding.Spec.RequiredBy = mergeBindingSnapshot(existBinding.Spec.RequiredBy, attachedBinding.Spec.RequiredBy)
existBinding.Labels = util.DedupeAndMergeLabels(existBinding.Labels, attachedBinding.Labels)
existBinding.Spec.Resource = attachedBinding.Spec.Resource
Expand Down
Loading

0 comments on commit 908c04b

Please sign in to comment.