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
Generated clients using closed enums from an openapi snapshot are not forwards compatible #109177
Comments
/cc @jiahuif |
/milestone v1.24 |
@dims: The provided milestone is not valid for this repository. Milestones in this repository: [ Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/cc @leilajal |
Changes for 1.24 are merged, lowering priority and removing from milestone |
This still needs to be addressed in the KEP and coordinated with generated clients before the feature hits GA and our static snapshot unconditionally contains enum info |
This issue has not been updated in over 1 year, and should be re-triaged. You can:
For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/ /remove-triage accepted |
/triage accepted |
Discussed this with Alex. Enum is not a type here, the type is still string, int, or whatever. Clients should accept values that they don't know about since they might not know about the most recent versions. We need to work with client generators so that they don't generate enums that can't be be extended. |
My plan is to create a CLI tool to remove enum tags from openapi specs for generated clients. The trade-off is that such clients are not aware of the enums in any way unless they fetch the schema from the api server and parse themselves. How do you think of it? @apelisse |
I think that's wrong. It's not that clients shouldn't be aware of enums, they should be doing the right thing. They have plenty of options. If I was building a rust client, I would generate the following:
And clients should be able to generate such a thing. |
Because client generation uses standard OpenAPI client generator for each language, and there does not seem to be a "enum mode" switch, I guess the plan would be hack the generator for each language. |
😞 . You're right. Then yeah, maybe a tool to filter out the enum is the right way to go, though another option might be to talk to some of these standard openapi client generator to see if we can make that work? I still think it's a little weird to block any updates to enums. |
Related to generating clients using closed language-level enums based on kubernetes/enhancements#2887
Some of the currently marked
+enum
fields are documented to allow expansion in the future, which would break clients generated against earlier openapi schemas:These are only well-known types, other types are allowed:
This makes explicit reference to a future value we want to add:
We've regularly added new resourcequota scopes:
Docs reference "currently supported" values, which sounds like there could be expansion in the future:
More concerning, this breaks deserialization of new values by old generated clients using enums. I didn't see this aspect discussed in the KEP at all, and it's fairly significant.
Originally posted by @liggitt in #105057 (comment)
The text was updated successfully, but these errors were encountered: