diff --git a/controller/linodecluster_controller.go b/controller/linodecluster_controller.go index 2c720df68..d3298f2ac 100644 --- a/controller/linodecluster_controller.go +++ b/controller/linodecluster_controller.go @@ -48,9 +48,7 @@ import ( "github.com/linode/cluster-api-provider-linode/util/reconciler" ) -const ( - ConditionLoadBalancing clusterv1.ConditionType = "ConditionLoadBalancing" -) +const lbTypeDNS string = "dns" // LinodeClusterReconciler reconciles a LinodeCluster object type LinodeClusterReconciler struct { @@ -184,7 +182,6 @@ func (r *LinodeClusterReconciler) reconcile( logger.Error(err, "Failed to add Linode machine to loadbalancer option") return retryIfTransient(err) } - conditions.MarkTrue(clusterScope.LinodeCluster, ConditionLoadBalancing) return res, nil } @@ -206,7 +203,7 @@ func (r *LinodeClusterReconciler) reconcileCreate(ctx context.Context, logger lo } // handle creation for the loadbalancer for the control plane - if clusterScope.LinodeCluster.Spec.Network.LoadBalancerType == "dns" { + if clusterScope.LinodeCluster.Spec.Network.LoadBalancerType == lbTypeDNS { handleDNS(clusterScope) } else { if err := handleNBCreate(ctx, logger, clusterScope); err != nil { @@ -219,7 +216,7 @@ func (r *LinodeClusterReconciler) reconcileCreate(ctx context.Context, logger lo func (r *LinodeClusterReconciler) reconcileDelete(ctx context.Context, logger logr.Logger, clusterScope *scope.ClusterScope) error { logger.Info("deleting cluster") - if clusterScope.LinodeCluster.Spec.Network.NodeBalancerID == nil && !reconciler.ConditionTrue(clusterScope.LinodeCluster, ConditionLoadBalancing) { + if clusterScope.LinodeCluster.Spec.Network.NodeBalancerID == nil && clusterScope.LinodeCluster.Spec.Network.LoadBalancerType != lbTypeDNS { logger.Info("NodeBalancer ID is missing, nothing to do") if err := clusterScope.RemoveCredentialsRefFinalizer(ctx); err != nil { @@ -236,9 +233,8 @@ func (r *LinodeClusterReconciler) reconcileDelete(ctx context.Context, logger lo if err := removeMachineFromLB(ctx, logger, clusterScope); err != nil { return fmt.Errorf("remove machine from loadbalancer: %w", err) } - conditions.MarkFalse(clusterScope.LinodeCluster, ConditionLoadBalancing, "cleared loadbalancer", clusterv1.ConditionSeverityInfo, "") - if clusterScope.LinodeCluster.Spec.Network.LoadBalancerType != "dns" && clusterScope.LinodeCluster.Spec.Network.NodeBalancerID != nil { + if clusterScope.LinodeCluster.Spec.Network.LoadBalancerType != lbTypeDNS && clusterScope.LinodeCluster.Spec.Network.NodeBalancerID != nil { err := clusterScope.LinodeClient.DeleteNodeBalancer(ctx, *clusterScope.LinodeCluster.Spec.Network.NodeBalancerID) if util.IgnoreLinodeAPIError(err, http.StatusNotFound) != nil { logger.Error(err, "failed to delete NodeBalancer") diff --git a/controller/linodecluster_controller_test.go b/controller/linodecluster_controller_test.go index bcb35f5b8..a2d78ccc1 100644 --- a/controller/linodecluster_controller_test.go +++ b/controller/linodecluster_controller_test.go @@ -207,7 +207,7 @@ var _ = Describe("cluster-lifecycle", Ordered, Label("cluster", "cluster-lifecyc clusterKey := client.ObjectKeyFromObject(&linodeCluster) Expect(k8sClient.Get(ctx, clusterKey, &linodeCluster)).To(Succeed()) Expect(linodeCluster.Status.Ready).To(BeTrue()) - Expect(linodeCluster.Status.Conditions).To(HaveLen(2)) + Expect(linodeCluster.Status.Conditions).To(HaveLen(1)) Expect(linodeCluster.Status.Conditions[0].Type).To(Equal(clusterv1.ReadyCondition)) By("checking NB id") @@ -321,7 +321,7 @@ var _ = Describe("cluster-lifecycle-dns", Ordered, Label("cluster", "cluster-lif clusterKey := client.ObjectKeyFromObject(&linodeCluster) Expect(k8sClient.Get(ctx, clusterKey, &linodeCluster)).To(Succeed()) Expect(linodeCluster.Status.Ready).To(BeTrue()) - Expect(linodeCluster.Status.Conditions).To(HaveLen(2)) + Expect(linodeCluster.Status.Conditions).To(HaveLen(1)) Expect(linodeCluster.Status.Conditions[0].Type).To(Equal(clusterv1.ReadyCondition)) By("checking controlPlaneEndpoint/NB host and port") @@ -527,7 +527,7 @@ var _ = Describe("dns-override-endpoint", Ordered, Label("cluster", "dns-overrid clusterKey := client.ObjectKeyFromObject(&linodeCluster) Expect(k8sClient.Get(ctx, clusterKey, &linodeCluster)).To(Succeed()) Expect(linodeCluster.Status.Ready).To(BeTrue()) - Expect(linodeCluster.Status.Conditions).To(HaveLen(2)) + Expect(linodeCluster.Status.Conditions).To(HaveLen(1)) Expect(linodeCluster.Status.Conditions[0].Type).To(Equal(clusterv1.ReadyCondition)) By("checking controlPlaneEndpoint/NB host and port") diff --git a/controller/linodemachine_controller.go b/controller/linodemachine_controller.go index c045aac8c..6b51a6e3d 100644 --- a/controller/linodemachine_controller.go +++ b/controller/linodemachine_controller.go @@ -498,9 +498,6 @@ func (r *LinodeMachineReconciler) reconcileDelete( conditions.MarkFalse(machineScope.LinodeMachine, clusterv1.ReadyCondition, clusterv1.DeletedReason, clusterv1.ConditionSeverityInfo, "instance deleted") r.Recorder.Event(machineScope.LinodeMachine, corev1.EventTypeNormal, clusterv1.DeletedReason, "instance has cleaned up") - if reconciler.ConditionTrue(machineScope.LinodeCluster, ConditionLoadBalancing) { - return ctrl.Result{RequeueAfter: reconciler.DefaultMachineControllerRetryDelay}, nil - } machineScope.LinodeMachine.Spec.ProviderID = nil machineScope.LinodeMachine.Status.InstanceState = nil diff --git a/e2e/linodecluster-controller/minimal-linodecluster/chainsaw-test.yaml b/e2e/linodecluster-controller/minimal-linodecluster/chainsaw-test.yaml index 5b65c0d06..bb1703336 100755 --- a/e2e/linodecluster-controller/minimal-linodecluster/chainsaw-test.yaml +++ b/e2e/linodecluster-controller/minimal-linodecluster/chainsaw-test.yaml @@ -68,11 +68,6 @@ spec: results: 1 - name: Delete Cluster resource try: - - delete: - ref: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 - kind: LinodeCluster - name: ($cluster) - delete: ref: apiVersion: cluster.x-k8s.io/v1beta1 diff --git a/e2e/linodemachine-controller/minimal-linodemachine/chainsaw-test.yaml b/e2e/linodemachine-controller/minimal-linodemachine/chainsaw-test.yaml index 46526395f..6dc870d97 100755 --- a/e2e/linodemachine-controller/minimal-linodemachine/chainsaw-test.yaml +++ b/e2e/linodemachine-controller/minimal-linodemachine/chainsaw-test.yaml @@ -69,11 +69,6 @@ spec: results: 1 - name: Delete Cluster resource try: - - delete: - ref: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 - kind: LinodeCluster - name: ($cluster) - delete: ref: apiVersion: cluster.x-k8s.io/v1beta1 diff --git a/e2e/linodemachine-controller/vpc-integration/chainsaw-test.yaml b/e2e/linodemachine-controller/vpc-integration/chainsaw-test.yaml index b786edfc0..f346c442f 100755 --- a/e2e/linodemachine-controller/vpc-integration/chainsaw-test.yaml +++ b/e2e/linodemachine-controller/vpc-integration/chainsaw-test.yaml @@ -106,11 +106,6 @@ spec: - active: true - name: Delete the Cluster & LinodeVPC resource try: - - delete: - ref: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 - kind: LinodeCluster - name: ($cluster) - delete: ref: apiVersion: cluster.x-k8s.io/v1beta1