Skip to content

Conversation

fiunchinho
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

When a Cluster CR is deleted, CAPA takes care of deleting the dependant CRs in an specific order, i.e. first the worker nodes, then the control plane, and finally the infra cluster CR AWSCluster. Removing everything can take a little while, depending on the size of the cluster. While things are getting removed, the awscluster_controllerl keeps reconciling the AWSCluster, trying to keep the AWS resources such as the VPC or subnets up to date. But these resources will be removed shortly.
With the changes on this PR, we are skipping the reconciliation of the AWSCluster when the owner Cluster has been set for deletion. That way we skip reconciliation loops done on resources that are about to be removed, saving CAPA resources and AWS API calls.

Special notes for your reviewer:

Checklist:

  • squashed commits
  • includes documentation
  • includes emoji in title
  • adds unit tests
  • adds or updates e2e tests

Release note:

Skip AWSCluster reconciliation when owner Cluster is being deleted

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 22, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign fabriziopandini for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 22, 2025
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 22, 2025
@fiunchinho
Copy link
Contributor Author

/test pull-cluster-api-provider-aws-e2e-blocking

@damdo
Copy link
Member

damdo commented Sep 22, 2025

Is this the recommended way of dealing with the reconciliation of the ProviderCluster when the owning Cluster is being deleted?

What are other providers doing in this occasion?

I had a quick look at CAPV and CAPG but they don't seem to be doing that:

@damdo
Copy link
Member

damdo commented Sep 22, 2025

^ cc. @chrischdi

@chrischdi
Copy link
Member

chrischdi commented Sep 23, 2025

I agree with @damdo on this.

From core CAPI perspective this is not defined clearly I think (did not find something clearly about this in the InfraCluster contract xref). But it also does not mention the deletion should be the way of the issue description. So I'd conclude it should not be like that.

From my point of view: the infracluster provider should take care of keeping the environment usable, so deletion can succeed successfully.

So for the sake of making deletion reliable, IMHO CAPA should continue to reconcile the AWSCluster. Otherwise this could lead to even take longer for getting deleted and maybe produce more costs.
E.g. if CAPI is not able anymore to drain machines in a normal way, or CSI is not able to detach volumes and CAPI's waiting for successful detachment, etc.

Do we have numbers on how much it could save in terms of CAPA resources and AWS API calls?
Maybe the reconciliation could be optimized in other ways instead to be more efficient, and not only for AWSCluster's that have their Cluster marked for deletion.

@fiunchinho
Copy link
Contributor Author

Is this the recommended way of dealing with the reconciliation of the ProviderCluster when the owning Cluster is being deleted?

What are other providers doing in this occasion?

I had a quick look at CAPV and CAPG but they don't seem to be doing that:

I don't think it's defined anywhere, it seems more like an oversight. But I don't see any downside of doing it this way, only the advantage of being more efficient.

I agree with @damdo on this.

From core CAPI perspective this is not defined clearly I think (did not find something clearly about this in the InfraCluster contract xref). But it also does not mention the deletion should be the way of the issue description. So I'd conclude it should not be like that.

From my point of view: the infracluster provider should take care of keeping the environment usable, so deletion can succeed successfully.

So for the sake of making deletion reliable, IMHO CAPA should continue to reconcile the AWSCluster. Otherwise this could lead to even take longer for getting deleted and maybe produce more costs. E.g. if CAPI is not able anymore to drain machines in a normal way, or CSI is not able to detach volumes and CAPI's waiting for successful detachment, etc.

Do we have numbers on how much it could save in terms of CAPA resources and AWS API calls? Maybe the reconciliation could be optimized in other ways instead to be more efficient, and not only for AWSCluster's that have their Cluster marked for deletion.

I'll close this if everyone is against it. Please, would you take care of adding this to the contract so that developers know what's mandatory from infra providers?

@fiunchinho fiunchinho closed this Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-priority release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants