Skip to content

Commit fb5674f

Browse files
committed
Skip AWSCluster deletion reconciliation once CAPA finalizer is gone
1 parent 988d136 commit fb5674f

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

controllers/awscluster_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ func (r *AWSClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
200200
}
201201

202202
func (r *AWSClusterReconciler) reconcileDelete(ctx context.Context, clusterScope *scope.ClusterScope) error {
203+
if !controllerutil.ContainsFinalizer(clusterScope.AWSCluster, infrav1.ClusterFinalizer) {
204+
clusterScope.Info("No finalizer on AWSCluster, skipping deletion reconciliation")
205+
return nil
206+
}
207+
203208
clusterScope.Info("Reconciling AWSCluster delete")
204209

205210
ec2svc := r.getEC2Service(clusterScope)

controllers/awscluster_controller_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ func TestAWSClusterReconcilerIntegrationTests(t *testing.T) {
374374
g.Expect(testEnv.Cleanup(ctx, &awsCluster, controllerIdentity, ns)).To(Succeed())
375375
})
376376

377+
awsCluster.Finalizers = []string{infrav1.ClusterFinalizer}
377378
cs, err := getClusterScope(awsCluster)
378379
g.Expect(err).To(BeNil())
379380

controllers/awscluster_controller_unit_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ func TestAWSClusterReconcileOperations(t *testing.T) {
401401
t.Run("Should successfully delete AWSCluster with Cluster Finalizer removed", func(t *testing.T) {
402402
g := NewWithT(t)
403403
awsCluster := getAWSCluster("test", "test")
404+
awsCluster.Finalizers = []string{infrav1.ClusterFinalizer}
404405
csClient := setup(t, &awsCluster)
405406
defer teardown()
406407
deleteCluster()

0 commit comments

Comments
 (0)