Skip to content

Commit 908c04b

Browse files
authored
Merge pull request #6053 from whitewindmills/automated-cherry-pick-of-#6034-upstream-release-1.10
Automated cherry pick of #6034: fix the attached binding deletion problem
2 parents 6ef2e5c + 9b9204f commit 908c04b

File tree

2 files changed

+650
-0
lines changed

2 files changed

+650
-0
lines changed

pkg/dependenciesdistributor/dependencies_distributor.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,18 @@ func (d *DependenciesDistributor) createOrUpdateAttachedBinding(attachedBinding
558558
bindingKey := client.ObjectKeyFromObject(attachedBinding)
559559
err := d.Client.Get(context.TODO(), bindingKey, existBinding)
560560
if err == nil {
561+
// If this binding exists and its owner is not the input object, return error and let garbage collector
562+
// delete this binding and try again later. See https://github.com/karmada-io/karmada/issues/6034.
563+
if ownerRef := metav1.GetControllerOfNoCopy(existBinding); ownerRef != nil && ownerRef.UID != attachedBinding.OwnerReferences[0].UID {
564+
return fmt.Errorf("failed to update resourceBinding(%s) due to different owner reference UID, will "+
565+
"try again later after binding is garbage collected, see https://github.com/karmada-io/karmada/issues/6034", bindingKey)
566+
}
567+
568+
// If the spec.Placement is nil, this means that existBinding is generated by the dependency mechanism.
569+
// If the spec.Placement is not nil, then it must be generated by PropagationPolicy.
570+
if existBinding.Spec.Placement == nil {
571+
existBinding.Spec.ConflictResolution = attachedBinding.Spec.ConflictResolution
572+
}
561573
existBinding.Spec.RequiredBy = mergeBindingSnapshot(existBinding.Spec.RequiredBy, attachedBinding.Spec.RequiredBy)
562574
existBinding.Labels = util.DedupeAndMergeLabels(existBinding.Labels, attachedBinding.Labels)
563575
existBinding.Spec.Resource = attachedBinding.Spec.Resource

0 commit comments

Comments
 (0)