Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
Callisto13 committed Dec 6, 2021
1 parent ef84900 commit 777c22c
Showing 3 changed files with 2 additions and 26 deletions.
6 changes: 0 additions & 6 deletions api/v1alpha1/microvmcluster_types.go
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 1 addition & 6 deletions controllers/microvmcluster_controller.go
Original file line number Diff line number Diff line change
@@ -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)
15 changes: 1 addition & 14 deletions controllers/microvmcluster_controller_test.go
Original file line number Diff line number Diff line change
@@ -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,6 @@ 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)
_, err = getMicrovmCluster(context.TODO(), client, testClusterName, testClusterNamespace)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(reconciled.Finalizers).To(HaveLen(0))
}

0 comments on commit 777c22c

Please sign in to comment.