diff --git a/operators/constellation-node-operator/controllers/autoscalingstrategy_controller.go b/operators/constellation-node-operator/controllers/autoscalingstrategy_controller.go index 23cb7dbbb..96b785118 100644 --- a/operators/constellation-node-operator/controllers/autoscalingstrategy_controller.go +++ b/operators/constellation-node-operator/controllers/autoscalingstrategy_controller.go @@ -216,9 +216,6 @@ func (r *AutoscalingStrategyReconciler) tryUpdateStatus(ctx context.Context, nam return err } autoscalingStrategy.Status = *status.DeepCopy() - if err := r.Status().Update(ctx, &autoscalingStrategy); err != nil { - return err - } - return nil + return r.Status().Update(ctx, &autoscalingStrategy) }) } diff --git a/operators/constellation-node-operator/controllers/nodeversion_controller.go b/operators/constellation-node-operator/controllers/nodeversion_controller.go index 1814403a6..b4d83afd6 100644 --- a/operators/constellation-node-operator/controllers/nodeversion_controller.go +++ b/operators/constellation-node-operator/controllers/nodeversion_controller.go @@ -743,10 +743,7 @@ func (r *NodeVersionReconciler) tryUpdateStatus(ctx context.Context, name types. return err } nodeVersion.Status = *status.DeepCopy() - if err := r.Status().Update(ctx, &nodeVersion); err != nil { - return err - } - return nil + return r.Status().Update(ctx, &nodeVersion) }) } diff --git a/operators/constellation-node-operator/controllers/nodeversion_controller_env_test.go b/operators/constellation-node-operator/controllers/nodeversion_controller_env_test.go index eff8644a3..a75cc4f69 100644 --- a/operators/constellation-node-operator/controllers/nodeversion_controller_env_test.go +++ b/operators/constellation-node-operator/controllers/nodeversion_controller_env_test.go @@ -246,7 +246,7 @@ var _ = Describe("NodeVersion controller", func() { Eventually(func() int { err := k8sClient.Get(ctx, nodeVersionLookupKey, nodeVersion) if err != nil { - return 0 + return 1 } return len(nodeVersion.Status.AwaitingAnnotation) }, timeout, interval).Should(Equal(0)) @@ -300,13 +300,18 @@ var _ = Describe("NodeVersion controller", func() { }, timeout, interval).Should(HaveKeyWithValue("custom-node-label", "custom-node-label-value")) By("marking the new node as ready") - secondNode.Status.Conditions = []corev1.NodeCondition{ - { - Type: corev1.NodeReady, - Status: corev1.ConditionTrue, - }, - } - Expect(k8sClient.Status().Update(ctx, secondNode)).Should(Succeed()) + Eventually(func() error { + if err := k8sClient.Get(ctx, secondNodeLookupKey, secondNode); err != nil { + return err + } + secondNode.Status.Conditions = []corev1.NodeCondition{ + { + Type: corev1.NodeReady, + Status: corev1.ConditionTrue, + }, + } + return k8sClient.Status().Update(ctx, secondNode) + }, timeout, interval).Should(Succeed()) By("waiting for a NodeMaintenance resource to be created") nodeMaintenance := &nodemaintenancev1beta1.NodeMaintenance{} @@ -316,10 +321,12 @@ var _ = Describe("NodeVersion controller", func() { By("marking the NodeMaintenance as successful") fakes.nodeStateGetter.setNodeState(updatev1alpha1.NodeStateTerminated) - nodeMaintenance.Status.Phase = nodemaintenancev1beta1.MaintenanceSucceeded - Expect(k8sClient.Status().Update(ctx, nodeMaintenance)).Should(Succeed()) Eventually(func() error { - return k8sClient.Get(ctx, nodeMaintenanceLookupKey, nodeMaintenance) + if err := k8sClient.Get(ctx, nodeMaintenanceLookupKey, nodeMaintenance); err != nil { + return err + } + nodeMaintenance.Status.Phase = nodemaintenancev1beta1.MaintenanceSucceeded + return k8sClient.Status().Update(ctx, nodeMaintenance) }, timeout, interval).Should(Succeed()) By("checking that the outdated node is removed") diff --git a/operators/constellation-node-operator/controllers/pendingnode_controller.go b/operators/constellation-node-operator/controllers/pendingnode_controller.go index adb9bdbb2..b9ed266d6 100644 --- a/operators/constellation-node-operator/controllers/pendingnode_controller.go +++ b/operators/constellation-node-operator/controllers/pendingnode_controller.go @@ -240,10 +240,7 @@ func (r *PendingNodeReconciler) tryUpdateStatus(ctx context.Context, name types. return err } pendingNode.Status = *status.DeepCopy() - if err := r.Status().Update(ctx, pendingNode); err != nil { - return err - } - return nil + return r.Status().Update(ctx, pendingNode) }) }