Skip to content

Commit 7ae3df4

Browse files
authored
[fix] remove ConditionLoadBalancing condition (#487)
1 parent 691cbb8 commit 7ae3df4

File tree

6 files changed

+7
-29
lines changed

6 files changed

+7
-29
lines changed

controller/linodecluster_controller.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ import (
4848
"github.com/linode/cluster-api-provider-linode/util/reconciler"
4949
)
5050

51-
const (
52-
ConditionLoadBalancing clusterv1.ConditionType = "ConditionLoadBalancing"
53-
)
51+
const lbTypeDNS string = "dns"
5452

5553
// LinodeClusterReconciler reconciles a LinodeCluster object
5654
type LinodeClusterReconciler struct {
@@ -184,7 +182,6 @@ func (r *LinodeClusterReconciler) reconcile(
184182
logger.Error(err, "Failed to add Linode machine to loadbalancer option")
185183
return retryIfTransient(err)
186184
}
187-
conditions.MarkTrue(clusterScope.LinodeCluster, ConditionLoadBalancing)
188185

189186
return res, nil
190187
}
@@ -206,7 +203,7 @@ func (r *LinodeClusterReconciler) reconcileCreate(ctx context.Context, logger lo
206203
}
207204

208205
// handle creation for the loadbalancer for the control plane
209-
if clusterScope.LinodeCluster.Spec.Network.LoadBalancerType == "dns" {
206+
if clusterScope.LinodeCluster.Spec.Network.LoadBalancerType == lbTypeDNS {
210207
handleDNS(clusterScope)
211208
} else {
212209
if err := handleNBCreate(ctx, logger, clusterScope); err != nil {
@@ -219,7 +216,7 @@ func (r *LinodeClusterReconciler) reconcileCreate(ctx context.Context, logger lo
219216

220217
func (r *LinodeClusterReconciler) reconcileDelete(ctx context.Context, logger logr.Logger, clusterScope *scope.ClusterScope) error {
221218
logger.Info("deleting cluster")
222-
if clusterScope.LinodeCluster.Spec.Network.NodeBalancerID == nil && !reconciler.ConditionTrue(clusterScope.LinodeCluster, ConditionLoadBalancing) {
219+
if clusterScope.LinodeCluster.Spec.Network.NodeBalancerID == nil && clusterScope.LinodeCluster.Spec.Network.LoadBalancerType != lbTypeDNS {
223220
logger.Info("NodeBalancer ID is missing, nothing to do")
224221

225222
if err := clusterScope.RemoveCredentialsRefFinalizer(ctx); err != nil {
@@ -236,9 +233,8 @@ func (r *LinodeClusterReconciler) reconcileDelete(ctx context.Context, logger lo
236233
if err := removeMachineFromLB(ctx, logger, clusterScope); err != nil {
237234
return fmt.Errorf("remove machine from loadbalancer: %w", err)
238235
}
239-
conditions.MarkFalse(clusterScope.LinodeCluster, ConditionLoadBalancing, "cleared loadbalancer", clusterv1.ConditionSeverityInfo, "")
240236

241-
if clusterScope.LinodeCluster.Spec.Network.LoadBalancerType != "dns" && clusterScope.LinodeCluster.Spec.Network.NodeBalancerID != nil {
237+
if clusterScope.LinodeCluster.Spec.Network.LoadBalancerType != lbTypeDNS && clusterScope.LinodeCluster.Spec.Network.NodeBalancerID != nil {
242238
err := clusterScope.LinodeClient.DeleteNodeBalancer(ctx, *clusterScope.LinodeCluster.Spec.Network.NodeBalancerID)
243239
if util.IgnoreLinodeAPIError(err, http.StatusNotFound) != nil {
244240
logger.Error(err, "failed to delete NodeBalancer")

controller/linodecluster_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ var _ = Describe("cluster-lifecycle", Ordered, Label("cluster", "cluster-lifecyc
207207
clusterKey := client.ObjectKeyFromObject(&linodeCluster)
208208
Expect(k8sClient.Get(ctx, clusterKey, &linodeCluster)).To(Succeed())
209209
Expect(linodeCluster.Status.Ready).To(BeTrue())
210-
Expect(linodeCluster.Status.Conditions).To(HaveLen(2))
210+
Expect(linodeCluster.Status.Conditions).To(HaveLen(1))
211211
Expect(linodeCluster.Status.Conditions[0].Type).To(Equal(clusterv1.ReadyCondition))
212212

213213
By("checking NB id")
@@ -321,7 +321,7 @@ var _ = Describe("cluster-lifecycle-dns", Ordered, Label("cluster", "cluster-lif
321321
clusterKey := client.ObjectKeyFromObject(&linodeCluster)
322322
Expect(k8sClient.Get(ctx, clusterKey, &linodeCluster)).To(Succeed())
323323
Expect(linodeCluster.Status.Ready).To(BeTrue())
324-
Expect(linodeCluster.Status.Conditions).To(HaveLen(2))
324+
Expect(linodeCluster.Status.Conditions).To(HaveLen(1))
325325
Expect(linodeCluster.Status.Conditions[0].Type).To(Equal(clusterv1.ReadyCondition))
326326

327327
By("checking controlPlaneEndpoint/NB host and port")
@@ -527,7 +527,7 @@ var _ = Describe("dns-override-endpoint", Ordered, Label("cluster", "dns-overrid
527527
clusterKey := client.ObjectKeyFromObject(&linodeCluster)
528528
Expect(k8sClient.Get(ctx, clusterKey, &linodeCluster)).To(Succeed())
529529
Expect(linodeCluster.Status.Ready).To(BeTrue())
530-
Expect(linodeCluster.Status.Conditions).To(HaveLen(2))
530+
Expect(linodeCluster.Status.Conditions).To(HaveLen(1))
531531
Expect(linodeCluster.Status.Conditions[0].Type).To(Equal(clusterv1.ReadyCondition))
532532

533533
By("checking controlPlaneEndpoint/NB host and port")

controller/linodemachine_controller.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,6 @@ func (r *LinodeMachineReconciler) reconcileDelete(
498498
conditions.MarkFalse(machineScope.LinodeMachine, clusterv1.ReadyCondition, clusterv1.DeletedReason, clusterv1.ConditionSeverityInfo, "instance deleted")
499499

500500
r.Recorder.Event(machineScope.LinodeMachine, corev1.EventTypeNormal, clusterv1.DeletedReason, "instance has cleaned up")
501-
if reconciler.ConditionTrue(machineScope.LinodeCluster, ConditionLoadBalancing) {
502-
return ctrl.Result{RequeueAfter: reconciler.DefaultMachineControllerRetryDelay}, nil
503-
}
504501

505502
machineScope.LinodeMachine.Spec.ProviderID = nil
506503
machineScope.LinodeMachine.Status.InstanceState = nil

e2e/linodecluster-controller/minimal-linodecluster/chainsaw-test.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ spec:
6868
results: 1
6969
- name: Delete Cluster resource
7070
try:
71-
- delete:
72-
ref:
73-
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
74-
kind: LinodeCluster
75-
name: ($cluster)
7671
- delete:
7772
ref:
7873
apiVersion: cluster.x-k8s.io/v1beta1

e2e/linodemachine-controller/minimal-linodemachine/chainsaw-test.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ spec:
6969
results: 1
7070
- name: Delete Cluster resource
7171
try:
72-
- delete:
73-
ref:
74-
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
75-
kind: LinodeCluster
76-
name: ($cluster)
7772
- delete:
7873
ref:
7974
apiVersion: cluster.x-k8s.io/v1beta1

e2e/linodemachine-controller/vpc-integration/chainsaw-test.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ spec:
106106
- active: true
107107
- name: Delete the Cluster & LinodeVPC resource
108108
try:
109-
- delete:
110-
ref:
111-
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
112-
kind: LinodeCluster
113-
name: ($cluster)
114109
- delete:
115110
ref:
116111
apiVersion: cluster.x-k8s.io/v1beta1

0 commit comments

Comments
 (0)