From 2281c853d893a1f7436f5d47ee1e909dc13cb93a Mon Sep 17 00:00:00 2001 From: Thomas Guettler Date: Thu, 9 Nov 2023 13:24:32 +0100 Subject: [PATCH] Set Condition, if creating external LB failed. --- .../controllers/dockercluster_controller.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/infrastructure/docker/internal/controllers/dockercluster_controller.go b/test/infrastructure/docker/internal/controllers/dockercluster_controller.go index 231be59eb2b9..b5ace259e65c 100644 --- a/test/infrastructure/docker/internal/controllers/dockercluster_controller.go +++ b/test/infrastructure/docker/internal/controllers/dockercluster_controller.go @@ -80,12 +80,6 @@ func (r *DockerClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reques log = log.WithValues("Cluster", klog.KObj(cluster)) ctx = ctrl.LoggerInto(ctx, log) - // Create a helper for managing a docker container hosting the loadbalancer. - externalLoadBalancer, err := docker.NewLoadBalancer(ctx, cluster, dockerCluster) - if err != nil { - return ctrl.Result{}, errors.Wrapf(err, "failed to create helper for managing the externalLoadBalancer") - } - // Initialize the patch helper patchHelper, err := patch.NewHelper(dockerCluster, r.Client) if err != nil { @@ -101,6 +95,13 @@ func (r *DockerClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reques } }() + // Create a helper for managing a docker container hosting the loadbalancer. + externalLoadBalancer, err := docker.NewLoadBalancer(ctx, cluster, dockerCluster) + if err != nil { + conditions.MarkFalse(dockerCluster, infrav1.LoadBalancerAvailableCondition, infrav1.LoadBalancerProvisioningFailedReason, clusterv1.ConditionSeverityWarning, err.Error()) + return ctrl.Result{}, errors.Wrapf(err, "failed to create helper for managing the externalLoadBalancer") + } + // Support FailureDomains // In cloud providers this would likely look up which failure domains are supported and set the status appropriately. // In the case of Docker, failure domains don't mean much so we simply copy the Spec into the Status.