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 sporadically doesn't respect storage-field in @Version annotation #5507

Closed
thomasdraebing opened this issue Oct 11, 2023 · 4 comments
Labels
Milestone

Comments

@thomasdraebing
Copy link

Describe the bug

When multiple versions for a single CustomResource exist and all but one set storage = false in the @Version annotation, the generated CRD sometimes (~50 % of the time) contains multiple versions with storage: true, which is invalid.

Fabric8 Kubernetes Client version

6.6.2

Steps to reproduce

  1. Create a CustomResource with two versions:
@Version(value = "v1beta1", storage = false)
public class Rsrc extends CustomResource<Spec, Status> {}

#different package
@Version(value = "v1beta2", storage = true)
public class Rsrc extends CustomResource<Spec, Status> {}
  1. Generate CRDs

Expected behavior

The generated CRD only contains a single version where storage is true.

Runtime

other (please specify in additional context)

Kubernetes API Server version

other (please specify in additional context)

Environment

macOS

Fabric8 Kubernetes Client Logs

08:21:39.936 [INFO ] io.fabric8.crd.generator.CRDGenerator:154 [PID:24549] - Generating 'receivers.gerritoperator.google.com' version 'v1beta2' with com.google.gerrit.k8s.operator.v1beta2.api.model.receiver.Receiver (spec: com.google.gerrit.k8s.operator.v1beta2.api.model.receiver.ReceiverSpec / status com.google.gerrit.k8s.operator.v1beta2.api.model.receiver.ReceiverStatus)...
08:21:40.433 [INFO ] io.fabric8.crd.generator.CRDGenerator:154 [PID:24549] - Generating 'gitgcs.gerritoperator.google.com' version 'v1beta1' with com.google.gerrit.k8s.operator.v1beta1.api.model.gitgc.GitGarbageCollection (spec: com.google.gerrit.k8s.operator.v1beta1.api.model.gitgc.GitGarbageCollectionSpec / status com.google.gerrit.k8s.operator.v1beta1.api.model.gitgc.GitGarbageCollectionStatus)...
08:21:40.505 [INFO ] io.fabric8.crd.generator.CRDGenerator:154 [PID:24549] - Generating 'receivers.gerritoperator.google.com' version 'v1beta1' with com.google.gerrit.k8s.operator.v1beta1.api.model.receiver.Receiver (spec: com.google.gerrit.k8s.operator.v1beta1.api.model.receiver.ReceiverSpec / status com.google.gerrit.k8s.operator.v1beta1.api.model.receiver.ReceiverStatus)...
08:21:40.949 [INFO ] io.fabric8.crd.generator.CRDGenerator:154 [PID:24549] - Generating 'gitgcs.gerritoperator.google.com' version 'v1beta2' with com.google.gerrit.k8s.operator.v1beta2.api.model.gitgc.GitGarbageCollection (spec: com.google.gerrit.k8s.operator.v1beta2.api.model.gitgc.GitGarbageCollectionSpec / status com.google.gerrit.k8s.operator.v1beta2.api.model.gitgc.GitGarbageCollectionStatus)...
08:21:41.017 [INFO ] io.fabric8.crd.generator.CRDGenerator:154 [PID:24549] - Generating 'gerritclusters.gerritoperator.google.com' version 'v1beta2' with com.google.gerrit.k8s.operator.v1beta2.api.model.cluster.GerritCluster (spec: com.google.gerrit.k8s.operator.v1beta2.api.model.cluster.GerritClusterSpec / status com.google.gerrit.k8s.operator.v1beta2.api.model.cluster.GerritClusterStatus)...
08:21:41.597 [INFO ] io.fabric8.crd.generator.CRDGenerator:154 [PID:24549] - Generating 'gerritclusters.gerritoperator.google.com' version 'v1beta1' with com.google.gerrit.k8s.operator.v1beta1.api.model.cluster.GerritCluster (spec: com.google.gerrit.k8s.operator.v1beta1.api.model.cluster.GerritClusterSpec / status com.google.gerrit.k8s.operator.v1beta1.api.model.cluster.GerritClusterStatus)...
08:21:42.187 [INFO ] io.fabric8.crd.generator.CRDGenerator:154 [PID:24549] - Generating 'gerrits.gerritoperator.google.com' version 'v1beta1' with com.google.gerrit.k8s.operator.v1beta1.api.model.gerrit.Gerrit (spec: com.google.gerrit.k8s.operator.v1beta1.api.model.gerrit.GerritSpec / status com.google.gerrit.k8s.operator.v1beta1.api.model.gerrit.GerritStatus)...
08:21:42.808 [INFO ] io.fabric8.crd.generator.CRDGenerator:154 [PID:24549] - Generating 'gerrits.gerritoperator.google.com' version 'v1beta2' with com.google.gerrit.k8s.operator.v1beta2.api.model.gerrit.Gerrit (spec: com.google.gerrit.k8s.operator.v1beta2.api.model.gerrit.GerritSpec / status com.google.gerrit.k8s.operator.v1beta2.api.model.gerrit.GerritStatus)...
08:21:43.334 [INFO ] io.fabric8.crd.generator.CRDGenerator:154 [PID:24549] - Generating 'gerritnetworks.gerritoperator.google.com' version 'v1beta2' with com.google.gerrit.k8s.operator.v1beta2.api.model.network.GerritNetwork (spec: com.google.gerrit.k8s.operator.v1beta2.api.model.network.GerritNetworkSpec / status io.fabric8.kubernetes.api.model.Status)...
08:21:43.485 [INFO ] io.fabric8.crd.generator.CRDGenerator:154 [PID:24549] - Generating 'gerritnetworks.gerritoperator.google.com' version 'v1beta1' with com.google.gerrit.k8s.operator.v1beta1.api.model.network.GerritNetwork (spec: com.google.gerrit.k8s.operator.v1beta1.api.model.network.GerritNetworkSpec / status io.fabric8.kubernetes.api.model.Status)...

Additional context

Kubernetes provider: Gardener
Kubernetes version: 1.26.7

@andreaTP
Copy link
Member

Hi @thomasdraebing and thanks for filing this issue!

I attempted to reproduce your issue here, and I think I'm hitting a slightly different(still not correct) behavior.

More specifically, when the 2 spec POJOs are identical I consistently get an exception in the tests:

 ZookeeperCustomResourceTest.testCrdv1beta1:56->lambda$testCrdv1beta1$1:57 NullPointer Cannot invoke "io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceValidation.getOpenAPIV3Schema()" because the return value of "io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionVersion.getSchema()" is null

If I add a random annotation on one of the fields(like the commented Max) the test consistently passes on my machine.

I think this is evidence enough that there are inconsistencies and, possibly, concurrency issues here.

I would be glad if @metacosm can take a peek at this one.

@andreaTP andreaTP added bug component/crd-generator Related to the CRD generator labels Oct 11, 2023
@sunix
Copy link
Collaborator

sunix commented Oct 17, 2023

As far as I remember @metacosm you were going to have a look. Feel free to unassign it if I was wrong. :)

Copy link

stale bot commented Jan 16, 2024

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@manusa
Copy link
Member

manusa commented Apr 29, 2024

This should have been fixed by #5846.

The latest released version of the client should work as expected: https://github.com/fabric8io/kubernetes-client/releases/tag/v6.12.1

@manusa manusa closed this as completed Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants