Skip to content

Commit d170574

Browse files
authored
Merge pull request kubernetes-sigs#9697 from guettli/mark-false-if-creating-lb-failed
🌱 CAPD: Set Condition, if creating external LB failed.
2 parents e55c6bf + 2281c85 commit d170574

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

test/infrastructure/docker/internal/controllers/dockercluster_controller.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ func (r *DockerClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reques
8080
log = log.WithValues("Cluster", klog.KObj(cluster))
8181
ctx = ctrl.LoggerInto(ctx, log)
8282

83-
// Create a helper for managing a docker container hosting the loadbalancer.
84-
externalLoadBalancer, err := docker.NewLoadBalancer(ctx, cluster, dockerCluster)
85-
if err != nil {
86-
return ctrl.Result{}, errors.Wrapf(err, "failed to create helper for managing the externalLoadBalancer")
87-
}
88-
8983
// Initialize the patch helper
9084
patchHelper, err := patch.NewHelper(dockerCluster, r.Client)
9185
if err != nil {
@@ -101,6 +95,13 @@ func (r *DockerClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reques
10195
}
10296
}()
10397

98+
// Create a helper for managing a docker container hosting the loadbalancer.
99+
externalLoadBalancer, err := docker.NewLoadBalancer(ctx, cluster, dockerCluster)
100+
if err != nil {
101+
conditions.MarkFalse(dockerCluster, infrav1.LoadBalancerAvailableCondition, infrav1.LoadBalancerProvisioningFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
102+
return ctrl.Result{}, errors.Wrapf(err, "failed to create helper for managing the externalLoadBalancer")
103+
}
104+
104105
// Support FailureDomains
105106
// In cloud providers this would likely look up which failure domains are supported and set the status appropriately.
106107
// In the case of Docker, failure domains don't mean much so we simply copy the Spec into the Status.

0 commit comments

Comments
 (0)