-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 -- Stack overflow when using EnumMap type in Spec #5584
CRD Generator -- Stack overflow when using EnumMap type in Spec #5584
Comments
Hi @bequinn-hubspot ! |
Hey @andreaTP thanks for the reply. I don't think that will work because then the field will no longer be stored in kubernetes. |
I'm from the phone and I will try to have a closer look tomorrow. |
@bequinn-hubspot thanks for your patience, I can reproduce the issue and the root cause is that The problem here is that the StackOverflow happens before the CRD generator logic kicks in We can exclude classes from the visiting algorithm, but it seems "artificial", and this situation can easily happen again. |
@andreaTP do you have a reproducer? |
yup, the provided repro does the job: 30adf7b |
Yes, I meant to include that I found it happens within AnnotatedPropertyPathDetector as well as the multi path detector.
|
Hey @andreaTP, I really appreciate how quickly you guys were able to take a look at this issue, thank you! I cherry picked that commit from #5588 and I was able to confirm that it did fix our infinite recursion issue. Unfortunately I did run into another separate, semi-related issue. In one of our classes we use guava's
That would normally be the expected result of a circular reference, however there is a jackson I think this may be a more general issue, where the class' shape isn't necessarily the same as the serialized object due to Jackson's support for modules, and the manipulation of serialization within those modules. The reason this is semi related is because it's another place where the CRD generation code diverges from how jackson handles things. That said, let me know if this would best be discussed elsewhere. |
@bequinn-hubspot it would probably be best to separate this - there are quite a few places the crd logic diverges or doesn't handle things from jackson. |
Ok, I'll open a separate issue |
Describe the bug
I'm seeing a stack overflow error in the CrdGenerator when defining a
java.util.EnumMap
as a private field. I believe the cause of this is due to the fact that the library is trying to introspect theClass<T> keyType
private field that is contained withinEnumMap
. Within theClass
type is aConcurrentHashMap
which has a bunch of circular references and that's where the generator gets into infinite recursion.This effects multiple versions of the client.
I believe this is caused by part of the design of the CRD generator, where it introspects private fields as the means of generating schemas. The fields that should be added to the spec/status schemas are the ones that will be serialized by Jackson when sending a CR instance to the kube api. The default behavior in Jackson is to look at public, non-static, non-transient fields. This is also the behavior of the serializer that is contained within fabric8. Therefore, the CRD generator should follow the same visibility rules.
I don't think that
private
,static
, ortransient
properties should be added to the schema, but rather the way schemas are generated should be inverted. First look at public, non-static, non-transient methods (getters) and then check to see if there's a matching private field to pull annotations from. I believe that is the behavior that is expected from jackson.Fabric8 Kubernetes Client version
SNAPSHOT
Steps to reproduce
Add
to any Spec or Status. Add it to
io.fabric8.crd.example.map.ContainingMapsSpec
to create a testable reproduction of the issue.Expected behavior
Runtime
Kubernetes (vanilla)
Kubernetes API Server version
1.25.3@latest
Environment
Linux
Fabric8 Kubernetes Client Logs
No response
Additional context
Stack trace for overflow
The text was updated successfully, but these errors were encountered: