Skip to content

Commit

Permalink
Merge pull request #4730 from giantswarm/delete-reconcile-only-with-f…
Browse files Browse the repository at this point in the history
…inalizer

✨ Skip AWSCluster deletion reconciliation once CAPA finalizer is gone
  • Loading branch information
k8s-ci-robot authored Jan 18, 2024
2 parents 0647b20 + fb5674f commit 3618d1c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
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

0 comments on commit 3618d1c

Please sign in to comment.