Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Skip AWSCluster deletion reconciliation once CAPA finalizer is gone #4730

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions controllers/awscluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ func (r *AWSClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
}

func (r *AWSClusterReconciler) reconcileDelete(ctx context.Context, clusterScope *scope.ClusterScope) error {
if !controllerutil.ContainsFinalizer(clusterScope.AWSCluster, infrav1.ClusterFinalizer) {
clusterScope.Info("No finalizer on AWSCluster, skipping deletion reconciliation")
return nil
}

clusterScope.Info("Reconciling AWSCluster delete")

ec2svc := r.getEC2Service(clusterScope)
Expand Down
1 change: 1 addition & 0 deletions controllers/awscluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ func TestAWSClusterReconcilerIntegrationTests(t *testing.T) {
g.Expect(testEnv.Cleanup(ctx, &awsCluster, controllerIdentity, ns)).To(Succeed())
})

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

Expand Down
1 change: 1 addition & 0 deletions controllers/awscluster_controller_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ func TestAWSClusterReconcileOperations(t *testing.T) {
t.Run("Should successfully delete AWSCluster with Cluster Finalizer removed", func(t *testing.T) {
g := NewWithT(t)
awsCluster := getAWSCluster("test", "test")
awsCluster.Finalizers = []string{infrav1.ClusterFinalizer}
csClient := setup(t, &awsCluster)
defer teardown()
deleteCluster()
Expand Down