From 5014a02bb2629b9ab14318e3ee0383782508b8db Mon Sep 17 00:00:00 2001 From: Claudia Beresford Date: Tue, 30 Nov 2021 12:18:28 +0000 Subject: [PATCH] Remove finalizers from Cluster We do not currently create any supporting infrastructure for our machines. We can add this back if we need it. --- api/v1alpha1/microvmcluster_types.go | 6 ------ controllers/microvmcluster_controller.go | 7 +------ controllers/microvmcluster_controller_test.go | 16 +--------------- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/api/v1alpha1/microvmcluster_types.go b/api/v1alpha1/microvmcluster_types.go index b2391b3..2d5e4d9 100644 --- a/api/v1alpha1/microvmcluster_types.go +++ b/api/v1alpha1/microvmcluster_types.go @@ -8,12 +8,6 @@ import ( clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) -const ( - // ClusterFinalizer allows ReconcileMicrovmCluster to clean up esources associated with MicrovmCluster before - // removing it from the apiserver. - ClusterFinalizer = "microvmcluster.infrastructure.cluster.x-k8s.io" -) - // MicrovmClusterSpec defines the desired state of MicrovmCluster. type MicrovmClusterSpec struct { // ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. diff --git a/controllers/microvmcluster_controller.go b/controllers/microvmcluster_controller.go index 47ceead..090ff20 100644 --- a/controllers/microvmcluster_controller.go +++ b/controllers/microvmcluster_controller.go @@ -24,7 +24,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" - "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/reconcile" @@ -120,9 +119,7 @@ func (r *MicrovmClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reque func (r *MicrovmClusterReconciler) reconcileDelete(_ context.Context, clusterScope *scope.ClusterScope) (reconcile.Result, error) { clusterScope.Info("Reconciling MicrovmCluster delete") - // TODO: do any required deletion - - controllerutil.RemoveFinalizer(clusterScope.MvmCluster, infrav1.ClusterFinalizer) + // We currently do not do any Cluster creation so there is nothing to delete. return reconcile.Result{}, nil } @@ -134,8 +131,6 @@ func (r *MicrovmClusterReconciler) reconcileNormal(ctx context.Context, clusterS return reconcile.Result{}, errControlplaneEndpointRequired } - controllerutil.AddFinalizer(clusterScope.MvmCluster, infrav1.ClusterFinalizer) - clusterScope.MvmCluster.Status.Ready = true available := r.isAPIServerAvailable(ctx, clusterScope) diff --git a/controllers/microvmcluster_controller_test.go b/controllers/microvmcluster_controller_test.go index be06614..fd0b091 100644 --- a/controllers/microvmcluster_controller_test.go +++ b/controllers/microvmcluster_controller_test.go @@ -42,8 +42,6 @@ func TestClusterReconciliationNoEndpoint(t *testing.T) { c := conditions.Get(reconciled, infrav1.LoadBalancerAvailableCondition) g.Expect(c).To(BeNil()) - - g.Expect(reconciled.Finalizers).To(HaveLen(0)) } func TestClusterReconciliationWithClusterEndpoint(t *testing.T) { @@ -89,8 +87,6 @@ func TestClusterReconciliationWithClusterEndpoint(t *testing.T) { c = conditions.Get(reconciled, clusterv1.ReadyCondition) g.Expect(c).ToNot(BeNil()) g.Expect(c.Status).To(Equal(corev1.ConditionTrue)) - - g.Expect(reconciled.Finalizers).To(HaveLen(1)) } func TestClusterReconciliationWithMvmClusterEndpoint(t *testing.T) { @@ -136,8 +132,6 @@ func TestClusterReconciliationWithMvmClusterEndpoint(t *testing.T) { c = conditions.Get(reconciled, clusterv1.ReadyCondition) g.Expect(c).ToNot(BeNil()) g.Expect(c.Status).To(Equal(corev1.ConditionTrue)) - - g.Expect(reconciled.Finalizers).To(HaveLen(1)) } func TestClusterReconciliationWithClusterEndpointAPIServerNotReady(t *testing.T) { @@ -177,8 +171,6 @@ func TestClusterReconciliationWithClusterEndpointAPIServerNotReady(t *testing.T) c = conditions.Get(reconciled, clusterv1.ReadyCondition) g.Expect(c).ToNot(BeNil()) g.Expect(c.Status).To(Equal(corev1.ConditionFalse)) - - g.Expect(reconciled.Finalizers).To(HaveLen(1)) } func TestClusterReconciliationMicrovmAlreadyDeleted(t *testing.T) { @@ -221,8 +213,6 @@ func TestClusterReconciliationNotOwner(t *testing.T) { c := conditions.Get(reconciled, infrav1.LoadBalancerAvailableCondition) g.Expect(c).To(BeNil()) - - g.Expect(reconciled.Finalizers).To(HaveLen(0)) } func TestClusterReconciliationWhenPaused(t *testing.T) { @@ -251,8 +241,6 @@ func TestClusterReconciliationWhenPaused(t *testing.T) { c := conditions.Get(reconciled, infrav1.LoadBalancerAvailableCondition) g.Expect(c).To(BeNil()) - - g.Expect(reconciled.Finalizers).To(HaveLen(0)) } func TestClusterReconciliationDelete(t *testing.T) { @@ -276,7 +264,5 @@ func TestClusterReconciliationDelete(t *testing.T) { g.Expect(result.RequeueAfter).To(Equal(time.Duration(0))) // TODO: when we move to envtest this should return an NotFound error. #30 - reconciled, err := getMicrovmCluster(context.TODO(), client, testClusterName, testClusterNamespace) - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(reconciled.Finalizers).To(HaveLen(0)) + _, err = getMicrovmCluster(context.TODO(), client, testClusterName, testClusterNamespace) }