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

Allow clusters to be deleted without deleting custom subnets. #1231

Closed
jwmay2012 opened this issue May 13, 2024 · 1 comment · Fixed by #1233
Closed

Allow clusters to be deleted without deleting custom subnets. #1231

jwmay2012 opened this issue May 13, 2024 · 1 comment · Fixed by #1233
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@jwmay2012
Copy link
Contributor

jwmay2012 commented May 13, 2024

/kind feature

Describe the solution you'd like
Allow custom subnets (those created outside of CAPG) to be retained upon cluster deletion.

Anything else you would like to add:

We create our Networks/SubNetworks outside CAPI and keep non-cluster machines in them. When we want to delete a cluster, the cluster.cluster.x-k8s.io finalizer never gets removed because CAPG forever tries and fails to delete the Network and SubNetwork because they contain other machines.

I would like to submit a PR to skip Network/SubNetwork deletion step in the func (r *GCPClusterReconciler) reconcileDelete(...) function.

Proposed Configuration Solutions

  1. Add a new option to the GCPCluster.Spec.Network spec. reclaimPolicy: Retain which would default to Delete. Based off PersistentVolumes retention policy convention. But any other name that works for this project would be fine.

  2. Use the Network Description to identify non-CAPG created networks, and refrain from deleting them. Networks and Subnetworks don't have GCP labels and seem to only have a Description for metadata. The Network description is set via infrav1.ClusterTagKey(s.Name()) which resolves to "cpag-cluster-" + Cluster.Metadata.Name. We could make this more obviously "machine created" by changing it to Created By CAPG: capg-cluster-mycluster:240f34f19636c80eeeb41ccf4dbd390b where the hash is md5|sha1|sha256|w/e of capg-cluster-mycluster. Then during cluster reconcileDelete, we check if the Network description matches our "machine created" string. If yes, then continue with default behavior auto-delete. If not, then we assume its not created by CAPG and skip deleting Network/SubNetwork.

Any other suggested/preferred configuration options would appreciated.

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label May 13, 2024
@jwmay2012
Copy link
Contributor Author

jwmay2012 commented May 13, 2024

I'm finding out more specifics about the issue.
Networks DO skip deletion if their description is not equal to infrav1.ClusterTagKey(s.Name()). Just noticed this.
Our issue is with SubNetworks not skipping in the same way.

I'll create a PR that adds this similar logic to subnets.

@jwmay2012 jwmay2012 changed the title Allow clusters to be deleted without deleting Networks/Subnetworks. Allow clusters to be deleted without deleting custom subnets. May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants