Skip to content

Commit cdae6cd

Browse files
committed
Remove finalizers from Cluster
We do not currently create any supporting infrastructure for our machines. We can add this back if we need it.
1 parent 2879582 commit cdae6cd

File tree

3 files changed

+2
-26
lines changed

3 files changed

+2
-26
lines changed

api/v1alpha1/microvmcluster_types.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ import (
88
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
99
)
1010

11-
const (
12-
// ClusterFinalizer allows ReconcileMicrovmCluster to clean up esources associated with MicrovmCluster before
13-
// removing it from the apiserver.
14-
ClusterFinalizer = "microvmcluster.infrastructure.cluster.x-k8s.io"
15-
)
16-
1711
// MicrovmClusterSpec defines the desired state of MicrovmCluster.
1812
type MicrovmClusterSpec struct {
1913
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.

controllers/microvmcluster_controller.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"sigs.k8s.io/controller-runtime/pkg/builder"
2525
"sigs.k8s.io/controller-runtime/pkg/client"
2626
"sigs.k8s.io/controller-runtime/pkg/controller"
27-
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2827
"sigs.k8s.io/controller-runtime/pkg/handler"
2928
"sigs.k8s.io/controller-runtime/pkg/log"
3029
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -120,9 +119,7 @@ func (r *MicrovmClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reque
120119
func (r *MicrovmClusterReconciler) reconcileDelete(_ context.Context, clusterScope *scope.ClusterScope) (reconcile.Result, error) {
121120
clusterScope.Info("Reconciling MicrovmCluster delete")
122121

123-
// TODO: do any required deletion
124-
125-
controllerutil.RemoveFinalizer(clusterScope.MvmCluster, infrav1.ClusterFinalizer)
122+
// We currently do not do any Cluster creation so there is nothing to delete.
126123

127124
return reconcile.Result{}, nil
128125
}
@@ -134,8 +131,6 @@ func (r *MicrovmClusterReconciler) reconcileNormal(ctx context.Context, clusterS
134131
return reconcile.Result{}, errControlplaneEndpointRequired
135132
}
136133

137-
controllerutil.AddFinalizer(clusterScope.MvmCluster, infrav1.ClusterFinalizer)
138-
139134
clusterScope.MvmCluster.Status.Ready = true
140135

141136
available := r.isAPIServerAvailable(ctx, clusterScope)

controllers/microvmcluster_controller_test.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ func TestClusterReconciliationNoEndpoint(t *testing.T) {
4242

4343
c := conditions.Get(reconciled, infrav1.LoadBalancerAvailableCondition)
4444
g.Expect(c).To(BeNil())
45-
46-
g.Expect(reconciled.Finalizers).To(HaveLen(0))
4745
}
4846

4947
func TestClusterReconciliationWithClusterEndpoint(t *testing.T) {
@@ -89,8 +87,6 @@ func TestClusterReconciliationWithClusterEndpoint(t *testing.T) {
8987
c = conditions.Get(reconciled, clusterv1.ReadyCondition)
9088
g.Expect(c).ToNot(BeNil())
9189
g.Expect(c.Status).To(Equal(corev1.ConditionTrue))
92-
93-
g.Expect(reconciled.Finalizers).To(HaveLen(1))
9490
}
9591

9692
func TestClusterReconciliationWithMvmClusterEndpoint(t *testing.T) {
@@ -136,8 +132,6 @@ func TestClusterReconciliationWithMvmClusterEndpoint(t *testing.T) {
136132
c = conditions.Get(reconciled, clusterv1.ReadyCondition)
137133
g.Expect(c).ToNot(BeNil())
138134
g.Expect(c.Status).To(Equal(corev1.ConditionTrue))
139-
140-
g.Expect(reconciled.Finalizers).To(HaveLen(1))
141135
}
142136

143137
func TestClusterReconciliationWithClusterEndpointAPIServerNotReady(t *testing.T) {
@@ -177,8 +171,6 @@ func TestClusterReconciliationWithClusterEndpointAPIServerNotReady(t *testing.T)
177171
c = conditions.Get(reconciled, clusterv1.ReadyCondition)
178172
g.Expect(c).ToNot(BeNil())
179173
g.Expect(c.Status).To(Equal(corev1.ConditionFalse))
180-
181-
g.Expect(reconciled.Finalizers).To(HaveLen(1))
182174
}
183175

184176
func TestClusterReconciliationMicrovmAlreadyDeleted(t *testing.T) {
@@ -221,8 +213,6 @@ func TestClusterReconciliationNotOwner(t *testing.T) {
221213

222214
c := conditions.Get(reconciled, infrav1.LoadBalancerAvailableCondition)
223215
g.Expect(c).To(BeNil())
224-
225-
g.Expect(reconciled.Finalizers).To(HaveLen(0))
226216
}
227217

228218
func TestClusterReconciliationWhenPaused(t *testing.T) {
@@ -251,8 +241,6 @@ func TestClusterReconciliationWhenPaused(t *testing.T) {
251241

252242
c := conditions.Get(reconciled, infrav1.LoadBalancerAvailableCondition)
253243
g.Expect(c).To(BeNil())
254-
255-
g.Expect(reconciled.Finalizers).To(HaveLen(0))
256244
}
257245

258246
func TestClusterReconciliationDelete(t *testing.T) {
@@ -276,7 +264,6 @@ func TestClusterReconciliationDelete(t *testing.T) {
276264
g.Expect(result.RequeueAfter).To(Equal(time.Duration(0)))
277265

278266
// TODO: when we move to envtest this should return an NotFound error. #30
279-
reconciled, err := getMicrovmCluster(context.TODO(), client, testClusterName, testClusterNamespace)
267+
_, err = getMicrovmCluster(context.TODO(), client, testClusterName, testClusterNamespace)
280268
g.Expect(err).NotTo(HaveOccurred())
281-
g.Expect(reconciled.Finalizers).To(HaveLen(0))
282269
}

0 commit comments

Comments
 (0)