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

KEP-2887: OpenAPI Enum Types to Beta #3184

Merged
merged 7 commits into from
Feb 3, 2022

Conversation

jiahuif
Copy link
Member

@jiahuif jiahuif commented Jan 25, 2022

  • One-line PR description:

This PR revises KEP-2887 for its beta graduation.

  • Issue link:
  • Other comments:

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 25, 2022
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 25, 2022
@jiahuif
Copy link
Member Author

jiahuif commented Jan 25, 2022

/assign @deads2k

for PRR

@k8s-ci-robot
Copy link
Contributor

@jiahuif: GitHub didn't allow me to assign the following users: PRR, for.

Note that only kubernetes members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @deads2k for PRR

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.

@jiahuif
Copy link
Member Author

jiahuif commented Jan 25, 2022

/assign @jpbetz @apelisse

type Foo string
type FooAlias = Foo
```
would result in the parser to treat FooAlias as a duplicated type. A workaround will be implemented during alpha-to-beta graduation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the workaround and how long do you anticipate the workaround existing?

@@ -580,13 +581,17 @@ feature flags will be enabled on some API servers and not others during the
rollout. Similarly, consider large clusters and how enablement/disablement
will rollout across nodes.
-->
If the API-server has multiple replicas, with some instances not yet enabling this feature,
whether the returned OpenAPI Spec contains enum types will depend on which instance holds the leader lock.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what leader lock?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I've been working too much with leader election recently. I meant depends on which instance handled the request.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@deads2k
Copy link
Contributor

deads2k commented Jan 27, 2022

I have questions about the design updates. the PRR lgtm

Copy link
Contributor

@sftim sftim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small nits

keps/sig-api-machinery/2887-openapi-enum-types/README.md Outdated Show resolved Hide resolved
keps/sig-api-machinery/2887-openapi-enum-types/README.md Outdated Show resolved Hide resolved
@jiahuif
Copy link
Member Author

jiahuif commented Feb 2, 2022

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Feb 2, 2022
@@ -351,6 +351,16 @@ const (

Here, `StorageMedium` can have infinite number of possible values, which disqualify it as an enum type.

The Go parser has a limitation on parsing type aliases. The parser cannot distinguish
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "the Go parser"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to "The parser of Go compiler"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really what we use for gengo to parse the types.go files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. the imported package was go/parser

```
would result in the parser to treat FooAlias and Foo as the same type.
As a result, `gengo` produce either `Foo` or `FooAlias` but not both.
As a workaround, during beta graduation, the enum parser will be updated to accept any name of the type.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super clear on what this means, what's the exact behavior that you think we can have? Maybe include the bug too where a lot of the discussion has been going on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or can we try to be less hand-wavy on what we'll do here? I'm not sure I understand what you're proposing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Externalizing this to an issue in kubernetes/gengo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still be happy if we could discuss here what we can expect as a solution.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that this issue should affect other markers too. I will keep it short in the KEP and describe it in a separate issue

@sttts
Copy link
Contributor

sttts commented Feb 3, 2022

Sgtm

However, as of 1.23, the enum marker is the only marker to be added to a type declaration, and would be the first marker to be affected.
Until there is a fix to `gengo`, the enum generator has the following limitations:
- the enum marker must not be added to aliases
- an aliased enum type or value SHOULD NOT have comments. Otherwise, the comments will be squashed with these of the original with undefined ordering.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

being able to detect this case is important so people's verify scripts work consistently, right?.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. This should be detectable with simple regex matching. I will add a note that in this release cycle either gengo gets a fix or I will add a check script to detect this.

@deads2k
Copy link
Contributor

deads2k commented Feb 3, 2022

PRR is good, but the discussion about how to handle the generator edge cases looks to need to resolution.

/approve

@apelisse has good questions about handling the generator. @apelisse please lgtm when appropriate.
/assign @apelisse

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, jiahuif

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 3, 2022
@apelisse
Copy link
Member

apelisse commented Feb 3, 2022

That's still a little hand-wavy, but it's also fairly minor and somewhat unrelated to the specific feature. I'm also confident we can figure out a reasonable solution.

Thanks.
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 3, 2022
@k8s-ci-robot k8s-ci-robot merged commit daa57ff into kubernetes:master Feb 3, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.24 milestone Feb 3, 2022
@jiahuif jiahuif deleted the kep/2887/to-beta branch March 2, 2022 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants