Skip to content

fixes for issues in capi-garbage-cleanup.sh

Thomas Morin requested to merge fix-garbage-collection into main

This MR fixes two issues:

  • cluster CAPI garbage collector removes XXXConfi... (#871 - closed) - this issue was due to the use of Kinds with a plural in one place and singular in another place (what is returned by kubectl get here for instance) - my understanding is that this issue was likely impacting other resources
  • the use of VSphereMachineTemplates.cluster.x-k8s.io instead of VSphereMachineTemplates.infrastructure.cluster.x-k8s.io in kubectl get (after the transformation of VSphereMachineTemplates.*cluster.x-k8s.io by VSphereMachineTemplates.cluster.x-k8s.io here): this issue was due possibly went unoticed - although the use of a fully-qualified resource kind is necessary only for VSphereMachineTemplates (without a fully-qualified name we would "collide" with a same-named cattle.io CRD), I opted for using fully-qualified names for all resources looked at by the script so that we can validate the code including on non-capv deployments

Additionally, I did two improvements:

  • add a safeguard so that we never delete a resource that still has ownerReferences
  • generate a Kubernetes event on deletion -- this may help us in the future

/cc @baburciu

Edited by Thomas Morin

Merge request reports