Skip to content

Commit

Permalink
Merge pull request #11688 from sbueringer/pr-patch-uid-diff
Browse files Browse the repository at this point in the history
🐛 Also patch external refs if the UID differs
  • Loading branch information
k8s-ci-robot authored Jan 15, 2025
2 parents 7b6626f + 3025f52 commit 07d97c6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/controllers/cluster/cluster_controller_phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func ensureOwnerRefAndLabel(ctx context.Context, c client.Client, obj *unstructu
APIVersion: clusterv1.GroupVersion.String(),
Kind: "Cluster",
Name: cluster.Name,
UID: cluster.UID,
Controller: ptr.To(true),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ func (r *Reconciler) reconcileExternal(ctx context.Context, clusterClass *cluste
APIVersion: clusterv1.GroupVersion.String(),
Kind: "ClusterClass",
Name: clusterClass.Name,
UID: clusterClass.UID,
}

if util.HasExactOwnerRef(obj.GetOwnerReferences(), desiredOwnerRef) {
Expand Down
1 change: 1 addition & 0 deletions internal/controllers/machine/machine_controller_phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (r *Reconciler) ensureExternalOwnershipAndWatch(ctx context.Context, cluste
APIVersion: clusterv1.GroupVersion.String(),
Kind: "Machine",
Name: m.Name,
UID: m.UID,
Controller: ptr.To(true),
}

Expand Down
1 change: 1 addition & 0 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ func HasExactOwnerRef(ownerReferences []metav1.OwnerReference, ref metav1.OwnerR
if r.APIVersion == ref.APIVersion &&
r.Kind == ref.Kind &&
r.Name == ref.Name &&
r.UID == ref.UID &&
ptr.Deref(r.Controller, false) == ptr.Deref(ref.Controller, false) {
return true
}
Expand Down

0 comments on commit 07d97c6

Please sign in to comment.