Skip to content

Commit

Permalink
Remove finalizers from Cluster
Browse files Browse the repository at this point in the history
We do not currently create any supporting infrastructure for our
machines. We can add this back if we need it.
  • Loading branch information
Callisto13 committed Nov 30, 2021
1 parent 1f185c1 commit 5014a02
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 27 deletions.
6 changes: 0 additions & 6 deletions api/v1alpha1/microvmcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 1 addition & 6 deletions controllers/microvmcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand All @@ -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)
Expand Down
16 changes: 1 addition & 15 deletions controllers/microvmcluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
}

0 comments on commit 5014a02

Please sign in to comment.