From 0a0a965b4c82fdaa1c517a18893bb8928c56ff34 Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Wed, 16 Oct 2024 14:02:12 +0200 Subject: [PATCH] fixes --- .../controllers/machineset/machineset_controller_test.go | 4 +++- internal/controllers/machineset/machineset_status.go | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/controllers/machineset/machineset_controller_test.go b/internal/controllers/machineset/machineset_controller_test.go index 7753c2aca6b5..2d4a7876b4ff 100644 --- a/internal/controllers/machineset/machineset_controller_test.go +++ b/internal/controllers/machineset/machineset_controller_test.go @@ -624,8 +624,10 @@ func TestMachineSetReconcile(t *testing.T) { Client: c, recorder: rec, } - _, _ = msr.Reconcile(ctx, request) + res, err := msr.Reconcile(ctx, request) g.Eventually(rec.Events).Should(Receive()) + _ = res + _ = err }) t.Run("reconcile successfully when labels are missing", func(t *testing.T) { diff --git a/internal/controllers/machineset/machineset_status.go b/internal/controllers/machineset/machineset_status.go index b6f23262c4c2..6e798ee4e879 100644 --- a/internal/controllers/machineset/machineset_status.go +++ b/internal/controllers/machineset/machineset_status.go @@ -35,10 +35,6 @@ import ( // comply with the recommendation in the Kubernetes API guidelines. // Note: v1beta1 conditions are not managed by this func. func (r *Reconciler) reconcileStatus(_ context.Context, s *scope) { - if s.machineSet.Status.V1Beta2 == nil { - s.machineSet.Status.V1Beta2 = &clusterv1.MachineSetV1Beta2Status{} - } - // Update the following fields in status from the machines list. // - ReadyReplicas // - AvailableReplicas @@ -77,6 +73,10 @@ func setReplicas(ms *clusterv1.MachineSet, machines []*clusterv1.Machine) { } } + if ms.Status.V1Beta2 == nil { + ms.Status.V1Beta2 = &clusterv1.MachineSetV1Beta2Status{} + } + ms.Status.V1Beta2.ReadyReplicas = ptr.To(readyReplicas) ms.Status.V1Beta2.AvailableReplicas = ptr.To(availableReplicas) } @@ -225,6 +225,7 @@ func setMachinesReadyCondition(machineSet *clusterv1.MachineSet, machines []*clu Reason: clusterv1.MachineSetMachineInvalidConditionReportedV1Beta2Reason, Message: err.Error(), }) + return } // Overwrite the message for the true case.