Skip to content

Commit 07d97c6

Browse files
authored
Merge pull request #11688 from sbueringer/pr-patch-uid-diff
🐛 Also patch external refs if the UID differs
2 parents 7b6626f + 3025f52 commit 07d97c6

File tree

4 files changed

+4
-0
lines changed

4 files changed

+4
-0
lines changed

internal/controllers/cluster/cluster_controller_phases.go

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ func ensureOwnerRefAndLabel(ctx context.Context, c client.Client, obj *unstructu
131131
APIVersion: clusterv1.GroupVersion.String(),
132132
Kind: "Cluster",
133133
Name: cluster.Name,
134+
UID: cluster.UID,
134135
Controller: ptr.To(true),
135136
}
136137

internal/controllers/clusterclass/clusterclass_controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ func (r *Reconciler) reconcileExternal(ctx context.Context, clusterClass *cluste
434434
APIVersion: clusterv1.GroupVersion.String(),
435435
Kind: "ClusterClass",
436436
Name: clusterClass.Name,
437+
UID: clusterClass.UID,
437438
}
438439

439440
if util.HasExactOwnerRef(obj.GetOwnerReferences(), desiredOwnerRef) {

internal/controllers/machine/machine_controller_phases.go

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func (r *Reconciler) ensureExternalOwnershipAndWatch(ctx context.Context, cluste
9898
APIVersion: clusterv1.GroupVersion.String(),
9999
Kind: "Machine",
100100
Name: m.Name,
101+
UID: m.UID,
101102
Controller: ptr.To(true),
102103
}
103104

util/util.go

+1
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ func HasExactOwnerRef(ownerReferences []metav1.OwnerReference, ref metav1.OwnerR
342342
if r.APIVersion == ref.APIVersion &&
343343
r.Kind == ref.Kind &&
344344
r.Name == ref.Name &&
345+
r.UID == ref.UID &&
345346
ptr.Deref(r.Controller, false) == ptr.Deref(ref.Controller, false) {
346347
return true
347348
}

0 commit comments

Comments
 (0)