From aed523b493f3f5bd52246d853bc9f4a4b852b5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20GLON?= Date: Tue, 3 Sep 2024 11:40:34 +0200 Subject: [PATCH] fix loadBalancer error not ctached --- controllers/osccluster_controller.go | 7 ++++++- .../oscmachinetemplate_capacity_controller_unit_test.go | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/controllers/osccluster_controller.go b/controllers/osccluster_controller.go index 562b8b5a5..85eba0737 100644 --- a/controllers/osccluster_controller.go +++ b/controllers/osccluster_controller.go @@ -405,7 +405,12 @@ func (r *OscClusterReconciler) reconcile(ctx context.Context, clusterScope *scop conditions.MarkTrue(osccluster, infrastructurev1beta1.RouteTablesReadyCondition) loadBalancerSvc := r.getLoadBalancerSvc(ctx, *clusterScope) - _, err = reconcileLoadBalancer(ctx, clusterScope, loadBalancerSvc, securityGroupSvc) + reconcileLoadBalancer, err := reconcileLoadBalancer(ctx, clusterScope, loadBalancerSvc, securityGroupSvc) + if err != nil { + clusterScope.Error(err, "failed to reconcile LoadBalancer") + conditions.MarkFalse(osccluster, infrastructurev1beta1.LoadBalancerReadyCondition, infrastructurev1beta1.LoadBalancerFailedReason, clusterv1.ConditionSeverityWarning, err.Error()) + return reconcileLoadBalancer, err + } if clusterScope.OscCluster.Spec.Network.Bastion.Enable { vmSvc := r.getVmSvc(ctx, *clusterScope) imageSvc := r.getImageSvc(ctx, *clusterScope) diff --git a/controllers/oscmachinetemplate_capacity_controller_unit_test.go b/controllers/oscmachinetemplate_capacity_controller_unit_test.go index 636d1974e..a7398b335 100644 --- a/controllers/oscmachinetemplate_capacity_controller_unit_test.go +++ b/controllers/oscmachinetemplate_capacity_controller_unit_test.go @@ -203,7 +203,9 @@ func TestReconcileCapacity(t *testing.T) { vmType := ctc.machineTemplateSpec.Template.Spec.Node.Vm.VmType capacity := make(corev1.ResourceList) memory, err := resource.ParseQuantity("4G") + assert.NoError(t, err) cpu, err := resource.ParseQuantity("2") + assert.NoError(t, err) capacity[corev1.ResourceMemory] = memory capacity[corev1.ResourceCPU] = cpu