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

CRDGenerator: Private CustomResource classes are found while scanning but cannot be processed #6685

Closed
baloo42 opened this issue Nov 30, 2024 · 0 comments · Fixed by #6686
Closed
Assignees
Milestone

Comments

@baloo42
Copy link
Contributor

baloo42 commented Nov 30, 2024

Describe the bug

CustomResource classes with private or package-private visability will be found by the CRDGenerator collector. But those cannot be processed by the CRDGenerator api-v2 because it is using reflection to instantiate the CustomResource class without modifying the constructors accessability.

https://github.com/fabric8io/kubernetes-client/blob/main/crd-generator/api-v2/src/main/java/io/fabric8/crdv2/generator/CustomResourceInfo.java#L168

getDeclaredConstructor() does only work with public classes.

Fabric8 Kubernetes Client version

SNAPSHOT

Steps to reproduce

baloo42/crd-generator-maven-examples#11

Expected behavior

We should align the behaviour of the collector and api-v2. Either we filter private and package-private custom resource classes in the collector, or we should modify the accessability of the constructor of the CustomResource in CustomResourceInfo before trying to instantiate it.

Runtime

Kubernetes (vanilla)

Kubernetes API Server version

1.25.3@latest

Environment

Linux

CRD-Generator Maven Plugin Logs

Caused by: java.lang.IllegalAccessException: class io.fabric8.crdv2.generator.CustomResourceInfo cannot access a member of class io.fabric8.crd.maven.example.api.v2.Multiple with modifiers ""
    at jdk.internal.reflect.Reflection.newIllegalAccessException (Reflection.java:392)
    at java.lang.reflect.AccessibleObject.checkAccess (AccessibleObject.java:674)
    at java.lang.reflect.Constructor.newInstanceWithCaller (Constructor.java:490)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:481)
    at io.fabric8.crdv2.generator.CustomResourceInfo.fromClass (CustomResourceInfo.java:168)
    at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:197)
    at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:179)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining (ArrayList.java:1625)
    at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:509)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:499)
    at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:575)
    at java.util.stream.AbstractPipeline.evaluateToArrayNode (AbstractPipeline.java:260)
    at java.util.stream.ReferencePipeline.toArray (ReferencePipeline.java:616)
    at io.fabric8.crdv2.generator.CRDGenerator.customResourceClasses (CRDGenerator.java:128)
    at io.fabric8.crd.generator.maven.plugin.CrdGeneratorMojo.execute (CrdGeneratorMojo.java:178)

Additional context

operator-framework/java-operator-sdk#2540
#6683

/cc @metacosm

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