kubernetes-sigs/cluster-api

Prevent removal of apiVersions while they are still used

Open

#8,566 opened on Apr 25, 2023

View on GitHub
 (28 comments) (0 reactions) (1 assignee)Go (1,532 forks)auto 404
area/apihelp wantedkind/featurepriority/important-longtermtriage/accepted

Repository metrics

Stars
 (4,267 stars)
PR merge metrics
 (PR metrics pending)

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

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: https://github.com/kubernetes-sigs/cluster-api/issues/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.

Contributor guide