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
Add Support for OpenAPIEnum in OpenAPI v2 #105057
Add Support for OpenAPIEnum in OpenAPI v2 #105057
Conversation
/sig api-machinery |
dcaf7b4
to
bb45339
Compare
/triage accepted |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: apelisse, cheftako, jiahuif, jpbetz, thockin The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/milestone v1.23 |
/retest |
this PR is breaking the openapi spec for the type
oddly, the latest openapi spec on the master branch doesnt have this issue tho.. |
@yue9944882 Thanks for checking. This is the fix #108639 |
@yue9944882 since this is committed into the release branch for 1.23, I think we can regenerate to fix this, right? |
As an aside, it seems like there's a mismatch in the generation/use of the committed openapi spec... it's being generated with all alpha features enabled, including alpha features impacting the content of the openapi spec (like this enum feature). That is then being used to generate decidedly non-alpha clients. The fact that an alpha, off-by-default feature in kubernetes/kubernetes broke generated clients is pretty concerning. I'm wondering if we should be generating the committed openapi only enabling alpha APIs, but not all alpha feature gates. |
Should we generate both openapi-spec, one with alpha enabled and one without? First it'd give us an opportunity to compare the two, make sure that alpha features generate the right thing, but also provide a more stable openapi for offline clients generation? |
maybe? |
yes, after the fix is picked we also need to wait until the next patch release. i guess 1-2 weeks is expected. i presume it's fine to preserve the alpha objects/fields in the openapi (as long as it doesnt break the backward-compatibility) b/c users may wanna opt-in to the alpha feature. but the enum change involved by this PR is a bit different. the crux is that there's no native enum type in golang, the so-called "enum" in golang doesnt have a hard requirement on the candidate values. e.g. for a |
Agreed. The more I think about this, the more concerning it is. First, some of the currently marked
Second, and 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. |
I opened #109177 to track this issue For 1.24, I opened #109178 to fix the CSR condition and omit enums from the static openapi snapshot to avoid propagating enums into generated clients until we understand the implications better. For 1.23, I picked that change back in #109179 as well, to fix the CSR condition and avoid exposing an alpha-level feature. |
#109179 is now merged to the release-1.23 branch, so regenerating a client from the HEAD of release-1.23 would resolve enum-based issues |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Prune enum types from schema if OpenAPIEnum feature is not enabled. Additionally, this PR provides a pattern to revert schema changes from alpha features.
Special notes for your reviewer:
vendor/
is actually from Enum type generator kube-openapi#242 as a result of dependency upgradek8s.io/kube-openapi
will also bumpgo.mod
files of all staging packages. That's why this PR touches so many SIGs.GetOpenAPIDefinitions
is roughly doubled, because it is constructed then overwritten while being traversed.swagger.json
) are generated from comments in Go source files. This PR does not author or change any comments of such types.Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: