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

patch crd status.storedVersions if it has deprecated/unknown values #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

miklezzzz
Copy link
Member

Considering the fact that a CRD's status.storedVersions list must not have entries missing in the .spec.versions part of the CRD, otherwise, a is invalid: status.storedVersions[2]: Invalid value: "v1beta": must appear in spec.versions error is thrown when applying a new version of the CRD containing a smaller subset of verions in .spec.versions, which is typical when discontinuing older versions of the CRD, it makes sense to compare and align storedVersions values against the new set of .spec.versions before updating the CRD.

Originally, it was advised to update storedVersions as part of an error-handling process, but the text of the error is a matter of change between k8s versions, which makes it trickier to catch.

Signed-off-by: Mikhail Scherba <mikhail.scherba@flant.com>
@miklezzzz miklezzzz added the enhancement New feature or request label Feb 25, 2025
@miklezzzz miklezzzz self-assigned this Feb 25, 2025
crVersions = append(crVersions, version.Name)
}

if !slices.Equal(crVersions, existCRD.Status.StoredVersions) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I'm confused with this.
It works nice if we have storedVersion: ["v1", "v1alpha1", "v1alpha2"] and versions: ["v1"]. Then the field will be syncronized

But we have the other case (kubectl get crd nodegroups.deckhouse.io -o yaml)
In the quite fresh cluster it has:

kubectl get crd nodegroups.deckhouse.io -o json | jq .spec.versions.[].name
"v1alpha1"
"v1alpha2"
"v1"

but

kubectl get crd nodegroups.deckhouse.io -o json | jq .status.storedVersions[]
"v1"

So, the field will be syncronized and will show invalid stored versions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the question is if we want to have all spec.versions items in storedVersions or not. What if we add to storedVersions only the versions with the storage: true attribute?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall a discussion about removing discontinued versions from storedVersions in context of the webhook handler being overutilized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants