-
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
Enhance Java generation from CRDs to ignore unknown properties #5432
Comments
Hi @mikebell90 and thanks for your interest in the java-generator! I would like you to expand a bit on the use case to make sure I understand it correctly. You want to deserialize newer versions of the CRs using the code generated from an older CRD. The desired behavior would be to ignore the additional properties. Is it correct? |
Basically yes, though ideally it would be targeted to specific fields or subobjects, since ignoring things can be dangerous! OTOH it's annoying everytime a minor CRD patch comes out that we have to release a whole new controller immediately avoid deserialization errors.
|
As I see it on top of my head, probably, restoring the possibility to add Just to spell it out, I think that what we are discussing here is pretty dangerous, and a new version should correspond to a rebuild, but I understand the pain if fast release cycles of the CRDs are happening and automation is not perfect. Another specific work-around would be to instruct the fabric8 deserializer to ignore unknown fields, which is probably even worse than the former option (and I'll need @shawkins input on how to do it currently). Thoughts? |
Let's make sure we have a common understanding of what is happening:
Are you then are trying to deserialize something from rev 2 with the rev 1 object model? If that's the case then yes additionalProperties is the right way to do this - that will ensure round tripping with the rev 1 objects won't drop anything. Changing the object mapper to simply ignore unknown fields will cause those fields to be dropped if you are doing any updating. |
Just to state my position here:
|
Aren't conversion hooks supposed to deal specifically with this scenario? |
That's totally correct, and the first suggestion is to automate the version bumps.
Please note that the last step is not "expected" by the user who made a backward-compatible change and webhooks are not used in such circumstances. |
I'm not against the change (I like it and probably suggested the inclusion of that field some time ago). There are many other situations where this can come in handy I brought the point because I think it's important to highlight that the recommended and proper approach for this situation is to use conversion hooks. |
Completely agreed 👍 |
Is your enhancement related to a problem? Please describe
We are generating a huge number of Pojos from a set of CRDs. Recently the CRds were updated and added some more properties. While there's argument either way, it would nice to be ignore added properties
As you can see they added
numIncludedHosts
Describe the solution you'd like
A way to ignore these, ideally on a targeted basis
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: