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