From 8e8daf917aded5017c2000ab4dae4389d93a2465 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Wed, 27 May 2020 11:39:24 +0100 Subject: [PATCH] Update machine-api-operator dependency --- go.mod | 2 +- go.sum | 4 +-- .../pkg/controller/machine/controller.go | 32 ++++++++++++++----- vendor/modules.txt | 2 +- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index e31f81a9f2..7ad38cf029 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/golang/mock v1.2.0 github.com/onsi/ginkgo v1.12.0 github.com/onsi/gomega v1.8.1 - github.com/openshift/machine-api-operator v0.2.1-0.20200520080344-fe76daf636f4 + github.com/openshift/machine-api-operator v0.2.1-0.20200527204437-14e5e0c7d862 // kube 1.18 k8s.io/api v0.18.2 diff --git a/go.sum b/go.sum index 50e8c26930..45f56c5cfd 100644 --- a/go.sum +++ b/go.sum @@ -354,8 +354,8 @@ github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160/go.mo github.com/openshift/build-machinery-go v0.0.0-20200424080330-082bf86082cc/go.mod h1:1CkcsT3aVebzRBzVTSbiKSkJMsC/CASqxesfqEMfJEc= github.com/openshift/client-go v0.0.0-20200326155132-2a6cd50aedd0/go.mod h1:uUQ4LClRO+fg5MF/P6QxjMCb1C9f7Oh4RKepftDnEJE= github.com/openshift/library-go v0.0.0-20200512120242-21a1ff978534/go.mod h1:2kWwXTkpoQJUN3jZ3QW88EIY1hdRMqxgRs2hheEW/pg= -github.com/openshift/machine-api-operator v0.2.1-0.20200520080344-fe76daf636f4 h1:rKZ4E7Uo3NlgrLxvRJuyXVVDnFIsIJrA08R2JXqxK9w= -github.com/openshift/machine-api-operator v0.2.1-0.20200520080344-fe76daf636f4/go.mod h1:YKEQMHjXzrzm4fQGTyHBafFfQ/Yq/FrV+1YcGdPCp+0= +github.com/openshift/machine-api-operator v0.2.1-0.20200527204437-14e5e0c7d862 h1:uI/6lz/E7ngKe0Fy0wy/wOpLuoS8eJlmoyuLLYfK1bs= +github.com/openshift/machine-api-operator v0.2.1-0.20200527204437-14e5e0c7d862/go.mod h1:YKEQMHjXzrzm4fQGTyHBafFfQ/Yq/FrV+1YcGdPCp+0= github.com/operator-framework/operator-sdk v0.5.1-0.20190301204940-c2efe6f74e7b/go.mod h1:iVyukRkam5JZa8AnjYf+/G3rk7JI1+M6GsU0sq0B9NA= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= diff --git a/vendor/github.com/openshift/machine-api-operator/pkg/controller/machine/controller.go b/vendor/github.com/openshift/machine-api-operator/pkg/controller/machine/controller.go index 36f3324e80..8b84b7e0ab 100644 --- a/vendor/github.com/openshift/machine-api-operator/pkg/controller/machine/controller.go +++ b/vendor/github.com/openshift/machine-api-operator/pkg/controller/machine/controller.go @@ -422,6 +422,18 @@ func isInvalidMachineConfigurationError(err error) bool { func (r *ReconcileMachine) setPhase(machine *machinev1.Machine, phase string, errorMessage string) error { if stringPointerDeref(machine.Status.Phase) != phase { klog.V(3).Infof("%v: going into phase %q", machine.GetName(), phase) + // A call to Patch will mutate our local copy of the machine to match what is stored in the API. + // Before we make any changes to the status subresource on our local copy, we need to patch the object first, + // otherwise our local changes to the status subresource will be lost. + if phase == phaseFailed { + err := r.patchFailedMachineInstanceAnnotation(machine) + if err != nil { + klog.Errorf("Failed to update machine %q: %v", machine.GetName(), err) + return err + } + } + + // Since we may have mutated the local copy of the machine above, we need to calculate baseToPatch here. baseToPatch := client.MergeFrom(machine.DeepCopy()) machine.Status.Phase = &phase machine.Status.ErrorMessage = nil @@ -429,14 +441,6 @@ func (r *ReconcileMachine) setPhase(machine *machinev1.Machine, phase string, er machine.Status.LastUpdated = &now if phase == phaseFailed && errorMessage != "" { machine.Status.ErrorMessage = &errorMessage - if machine.Annotations == nil { - machine.Annotations = map[string]string{} - } - machine.Annotations[MachineInstanceStateAnnotationName] = unknownInstanceState - if err := r.Client.Patch(context.Background(), machine, baseToPatch); err != nil { - klog.Errorf("Failed to update machine %q: %v", machine.GetName(), err) - return err - } } if err := r.Client.Status().Patch(context.Background(), machine, baseToPatch); err != nil { klog.Errorf("Failed to update machine status %q: %v", machine.GetName(), err) @@ -446,6 +450,18 @@ func (r *ReconcileMachine) setPhase(machine *machinev1.Machine, phase string, er return nil } +func (r *ReconcileMachine) patchFailedMachineInstanceAnnotation(machine *machinev1.Machine) error { + baseToPatch := client.MergeFrom(machine.DeepCopy()) + if machine.Annotations == nil { + machine.Annotations = map[string]string{} + } + machine.Annotations[MachineInstanceStateAnnotationName] = unknownInstanceState + if err := r.Client.Patch(context.Background(), machine, baseToPatch); err != nil { + return err + } + return nil +} + func machineIsProvisioned(machine *machinev1.Machine) bool { return len(machine.Status.Addresses) > 0 || stringPointerDeref(machine.Spec.ProviderID) != "" } diff --git a/vendor/modules.txt b/vendor/modules.txt index ecc01940b0..1ac7074de9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -186,7 +186,7 @@ github.com/onsi/gomega/matchers/support/goraph/edge github.com/onsi/gomega/matchers/support/goraph/node github.com/onsi/gomega/matchers/support/goraph/util github.com/onsi/gomega/types -# github.com/openshift/machine-api-operator v0.2.1-0.20200520080344-fe76daf636f4 +# github.com/openshift/machine-api-operator v0.2.1-0.20200527204437-14e5e0c7d862 github.com/openshift/machine-api-operator/pkg/apis/machine github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1 github.com/openshift/machine-api-operator/pkg/controller/machine