Unable to replace the crd perconaservermongodbs.psmdb.percona.com on v1.17.0

Description:

We upgraded the mongodb from version 6 to 7 and I’m unable to apply the crd perconaservermongodbs.psmdb.percona.com from tag v.1.17.0

Steps to Reproduce:

k replace -f psmdb.percona.com_perconaservermongodbs.yaml
The CustomResourceDefinition "perconaservermongodbs.psmdb.percona.com" is invalid: status.storedVersions[0]: Invalid value: "v1-12-0": must appear in spec.versions

Version:

1.17.0

Hi @raj28, could you please try with kubectl apply rather than kubectl replace?

You probably will need to add --server-side flag too, so command will look like:

kubectl apply --server-side -f psmdb.percona.com_perconaservermongodbs.yaml

@Ege_Gunes Same error.

kubectl apply --server-side -f psmdb.percona.com_perconaservermongodbs.yaml
The CustomResourceDefinition "perconaservermongodbs.psmdb.percona.com" is invalid: status.storedVersions[0]: Invalid value: "v1-12-0": must appear in spec.versions

@Ege_Gunes Any ideas on how I can resolve this ?

Hi @raj28, normally this shouldn’t happen because we didn’t remove v1-12-0 from our CRD in v1.17.0. Could you please send me the status section from this command’s output?

kubectl get crd perconaservermongodbs.psmdb.percona.com -o yaml

@Ege_Gunes Please find the attached. I changed the extension from yaml to txt for attachment.
perconaservermongodbs.psmdb.percona.com.txt (771.0 KB)

status:
  acceptedNames:
    kind: PerconaServerMongoDB
    listKind: PerconaServerMongoDBList
    plural: perconaservermongodbs
    shortNames:
    - psmdb
    singular: perconaservermongodb
  conditions:
  - lastTransitionTime: "2022-05-20T17:59:24Z"
    message: no conflicts found
    reason: NoConflicts
    status: "True"
    type: NamesAccepted
  - lastTransitionTime: "2022-05-20T17:59:25Z"
    message: the initial names have been accepted
    reason: InitialNamesAccepted
    status: "True"
    type: Established
  storedVersions:
  - v1-12-0
  - v1

@raj28 you can fix the issue by running the following commands:

$ kubectl proxy & 
$ curl \
	--header "Content-Type: application/json-patch+json" \
	--request PATCH \
	--data '[{"op": "replace", "path": "/status/storedVersions", "value":["v1"]}]' \	http://localhost:8001/apis/apiextensions.k8s.io/v1/customresourcedefinitions/perconaservermongodbs.psmdb.percona.com/status

this will remove v1-12-0 from your CRD status. but, again, it’s strange that you have this problem since we still have v1-12-0 in v1.17.0 CRD.