Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#288 from alexander-demichev/fix-patch
Browse files Browse the repository at this point in the history
Bug 1796599: Save status before Patch()
  • Loading branch information
openshift-merge-robot authored Feb 4, 2020
2 parents 59ba191 + 565f194 commit 0df2d10
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/actuators/machine/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,12 +629,16 @@ func getClusterID(machine *machinev1.Machine) (string, bool) {
}

func (a *Actuator) patchMachine(ctx context.Context, machine *machinev1.Machine, machineToBePatched client.Patch) error {
statusCopy := *machine.Status.DeepCopy()

// Patch machine
if err := a.client.Patch(ctx, machine, machineToBePatched); err != nil {
klog.Errorf("Failed to update machine %q: %v", machine.GetName(), err)
return err
}

machine.Status = statusCopy

//Patch status
if err := a.client.Status().Patch(ctx, machine, machineToBePatched); err != nil {
klog.Errorf("Failed to update machine %q: %v", machine.GetName(), err)
Expand Down

0 comments on commit 0df2d10

Please sign in to comment.