Skip to content

Commit 537e4b1

Browse files
sbueringerk8s-infra-cherrypick-robot
authored andcommitted
Also patch external refs if the UID differs
Signed-off-by: Stefan Büringer [email protected]
1 parent b127c62 commit 537e4b1

File tree

4 files changed

+4
-0
lines changed

4 files changed

+4
-0
lines changed

internal/controllers/cluster/cluster_controller_phases.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ func ensureOwnerRefAndLabel(ctx context.Context, c client.Client, obj *unstructu
134134
APIVersion: clusterv1.GroupVersion.String(),
135135
Kind: "Cluster",
136136
Name: cluster.Name,
137+
UID: cluster.UID,
137138
Controller: ptr.To(true),
138139
}
139140

internal/controllers/clusterclass/clusterclass_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ func (r *Reconciler) reconcileExternal(ctx context.Context, clusterClass *cluste
401401
APIVersion: clusterv1.GroupVersion.String(),
402402
Kind: "ClusterClass",
403403
Name: clusterClass.Name,
404+
UID: clusterClass.UID,
404405
}
405406

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

internal/controllers/machine/machine_controller_phases.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ func (r *Reconciler) ensureExternalOwnershipAndWatch(ctx context.Context, cluste
149149
APIVersion: clusterv1.GroupVersion.String(),
150150
Kind: "Machine",
151151
Name: m.Name,
152+
UID: m.UID,
152153
Controller: ptr.To(true),
153154
}
154155

util/util.go

Lines changed: 1 addition & 0 deletions
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)