Description
What would you like to be added (User Story)?
As a user it would be nice if Cluster API would block removal of apiVersions of CRDs as long as they are still used.
Detailed Description
Today it is possible that during a Cluster API upgrade (e.g. when bumping an infra provider) an apiVersion is removed. If this apiVersion was still referenced in other resources, they won't reconcile anymore.
Affected resources:
- ClusterClass
- Cluster, MD, MS, Machine, ...
- Refs are probably not affected as they don't actually use the apiVersion from the object spec (they calculate the version they use based on the contract label on the CRD).
- Would be good to double check this again.
- OwnerRefs
- They might not be super relevant as our controllers always keep the ownerRefs up-to-date
- Refs are probably not affected as they don't actually use the apiVersion from the object spec (they calculate the version they use based on the contract label on the CRD).
A possible solution is to implement a webhook which validates CRD updates. In this webhook we could check if the update on the CRD removes an apiVersion which is still referenced in relevant resources (at least ClusterClass).
Note: This webhook should probably have failurePolicy: Ignore to avoid deadlocks if Cluster API is not working for some reason.
Anything else you would like to add?
Somewhat related: #6539 (as it might lead to us dropping apiVersion from all our refs except the ones in ClusterClass)
Label(s) to be applied
/kind feature
One or more /area label. See https://github.com/kubernetes-sigs/cluster-api/labels?q=area for the list of labels.