Skip to content

Commit a8335ed

Browse files
committed
fix: nodelink use patch to apply machine's nodeRef
1 parent 904c536 commit a8335ed

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/controller/nodelink/nodelink_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ func (r *ReconcileNodeLink) Reconcile(ctx context.Context, request reconcile.Req
259259
// updateNodeRef set the given node as nodeRef in the machine status
260260
func (r *ReconcileNodeLink) updateNodeRef(machine *machinev1.Machine, node *corev1.Node) error {
261261
now := metav1.Now()
262+
machineCopy := machine.DeepCopy()
262263
machine.Status.LastUpdated = &now
263264

264265
if !node.DeletionTimestamp.IsZero() {
@@ -280,7 +281,7 @@ func (r *ReconcileNodeLink) updateNodeRef(machine *machinev1.Machine, node *core
280281
Name: node.GetName(),
281282
UID: node.GetUID(),
282283
}
283-
if err := r.client.Status().Update(context.Background(), machine); err != nil {
284+
if err := r.client.Status().Patch(context.Background(), machine, client.MergeFrom(machineCopy)); err != nil {
284285
return fmt.Errorf("error updating machine %q: %v", machine.GetName(), err)
285286
}
286287
r.nodeReadinessCache[node.GetName()] = nodeReady

0 commit comments

Comments
 (0)