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

CRD Generator is not generating multiple custom resource versions in case one version is tied to a reconciler #886

Closed
moayad-alyaghshi opened this issue May 24, 2024 · 9 comments · Fixed by #973
Assignees

Comments

@moayad-alyaghshi
Copy link

Hi,

Fabric8 CRD generator supports multiple versions of the same kind:
https://github.com/fabric8io/kubernetes-client/blob/main/doc/CRD-generator.md#multiple-custom-resource-versions

This does not work for us. We have two versions (v1 and v2) of the same custom resource. We set quarkus.operator-sdk.crd.generate-all to true. When no version is tied to a reconciler, both versions will be generated, but when we use one version (v2) by the reconciler, only this version is generated and the other (v1) is ignored.

Is this intended behavior or a bug?

note: Quarkus platform version is 3.10.2

@metacosm metacosm self-assigned this May 24, 2024
@metacosm
Copy link
Member

Sorry for getting back to you so late, could you elaborate on your use case a little as I'm not sure I understand correctly what you're trying to accomplish?

@moayad-alyaghshi
Copy link
Author

moayad-alyaghshi commented Sep 30, 2024

Hi metacosm,

We had in the beginning a custom resource with v1. This version was the only one available and it was tied to a reconciler, so it was auto generated from the java class using Fabric8 CRD generator and everything was working fine. Now the schema is changed, so we want to create v2, and we want the auto generated CRD to have both versions (v2 is stored, and v1 is only served).

Generating multiple custom resource versions is supported by Fabric8 CRD generator, which is mentioned here. We created another java class for the custom resource, annotated it with v2, and tied to the reconciler, but the result was not expected. This is the observed behavior:

The desired behavior that v2 is tied to a reconciler and both versions are generated, but we couldn't achieve that. Keep in mind that the issue here is old and the used Quarkus version is old (3.10.2), so not sure if anything changed since then.

I hope this explanation helps. I can provide you with a simple example in cased it is needed.
Thanks.

@metacosm
Copy link
Member

Hi @moayad-alyaghshi, ok, this is more or less what I understood but the clarification helps! Will look into it.

@metacosm
Copy link
Member

metacosm commented Oct 3, 2024

The two versions are actually generated in the same file, which is expected for CRDs. Now, the question is why quarkus.operator-sdk.crd.generate-all impact this when the CRs are not tied to reconcilers. Could you please detail the configuration of your CRs, in particular, their group, version and kind annotations?

@metacosm
Copy link
Member

metacosm commented Oct 3, 2024

I've opened #971 which shows the current behavior.

@moayad-alyaghshi
Copy link
Author

moayad-alyaghshi commented Oct 7, 2024

@metacosm
We just want to generate the two versions of the CR. we looked into quarkus.operator-sdk.crd.generate-all since we couldn't achieve that. Maybe we are missing something, but it seems that only versions which are tied to a reconciler are generated.

Attached is a simple example. There is a CR with two versions (only v2 is tied to a reconciler). We want both versions to be generated into the CRD.

code-with-quarkus.zip

@metacosm
Copy link
Member

metacosm commented Oct 7, 2024

Hi @moayad-alyaghshi,
There was indeed an issue which will be addressed in 6.8.3. However, I don't think it will be possible to generate both versions in separate files. They will be put in the same CRD. If I understand correctly, though, that would that be acceptable, right?

metacosm added a commit that referenced this issue Oct 7, 2024
Also fixes an issue with improperly recorded reconciler name and
handling of generic kubernetes resources.

Fixes #886

Signed-off-by: Chris Laprun <[email protected]>
@metacosm
Copy link
Member

metacosm commented Oct 7, 2024

Let me know if the associated PR solves your issue.

@moayad-alyaghshi
Copy link
Author

Yes, generating the versions in the same CRD file is acceptable.
Thank you

metacosm added a commit that referenced this issue Oct 8, 2024
#973)

Also fixes an issue with improperly recorded reconciler name and
handling of generic kubernetes resources.

Fixes #886

Signed-off-by: Chris Laprun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants