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

Preserve existing behavior with go1.22/1.23 alias type parsing #281

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

liggitt
Copy link
Member

@liggitt liggitt commented Sep 10, 2024

go/types returns different content for aliases in go1.23 by default, which breaks or unexpectedly modifies the type parsing / walking encountered by generators.

https://tip.golang.org/doc/go1.23#gotypespkggotypes

By default, go/types now produces Alias type nodes for type aliases. This behavior can be controlled by the GODEBUG gotypesalias flag. Its default has changed from 0 in Go 1.22 to 1 in Go 1.23.

Encountered when bumping k/k to go 1.23 - kubernetes/kubernetes#127271 (comment)

@k8s-ci-robot k8s-ci-robot requested a review from jpbetz September 10, 2024 21:35
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 10, 2024
@k8s-ci-robot k8s-ci-robot requested a review from sttts September 10, 2024 21:35
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 10, 2024
@liggitt
Copy link
Member Author

liggitt commented Sep 10, 2024

/hold for CI and validation in kubernetes

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 10, 2024
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 11, 2024
@liggitt
Copy link
Member Author

liggitt commented Sep 11, 2024

Testing in kubernetes/kubernetes#127271

@liggitt liggitt changed the title Add support for go1.22 type aliases Preserve existing behavior with go1.22/1.23 alias type parsing Sep 11, 2024
@liggitt
Copy link
Member Author

liggitt commented Sep 11, 2024

/hold cancel
/assign @thockin

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 11, 2024
Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

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

Looks correct. We should just rename gengo's own "alias" to "typedef".

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 11, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, 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 /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 Sep 11, 2024
@k8s-ci-robot k8s-ci-robot merged commit 2b36238 into kubernetes:master Sep 11, 2024
4 checks passed
sayboras added a commit to sayboras/gengo that referenced this pull request Sep 20, 2024
This is the manual backport of the below PR to v1.

Relates: kubernetes#281
sayboras added a commit to sayboras/gengo that referenced this pull request Sep 20, 2024
This is the manual backport of the below PR to v1.

Relates: kubernetes#281
Signed-off-by: Tam Mach <[email protected]>
@sayboras
Copy link

I came across this PR while working on cilium/cilium repo. Thanks a lot for your awesome work.

Not sure if this is the right place, I am just curious if k8s.io/gengo (not k8s.io/gengo/v2) is still supported. If yes, do we need to do the same for k8s.io/gengo package? Thanks.

@thockin
Copy link
Member

thockin commented Sep 20, 2024

gengo is EOL and will not receive such updates.

gengo/V2 has significantly changed internally, and we opted to declare it a "virtually private" repo, primarily for use in kubernetes. IOW, the compatibility contract is more or less waived.

Is cilium using gengo? I was not aware of that (didn't look too hard, honestly). If so, can you tell us more about the use-case?

@sayboras
Copy link

Thanks for your reply.

Is cilium using gengo? I was not aware of that (didn't look too hard, honestly). If so, can you tell us more about the use-case?

Cilium is using a forked deepequal, which still relies on gengo v1. It seems like the cleanest path is to upgrade to gengo/v2.

@thockin
Copy link
Member

thockin commented Sep 25, 2024

I see. I want to repeat, just so there's no confusion, gengo v2 is not really a supported api, and if you use it outside of the kubernetes project we're not making very strong API guarantees. That doesn't mean we're going to break it on purpose, but it might mean that we are a little cavalier about changes.

For example, we didn't really write a conversion guide for V1 users. So as you undertake this, if you undertake this, let me know if you struggle to figure out what changed.

@mtardy
Copy link
Member

mtardy commented Sep 30, 2024

Any chance we could get this fix into https://github.com/kubernetes/kubernetes/tree/master/staging/src/k8s.io/code-generator? Controller-gen is now fixed to work with the new Alias type but not code-generator yet.

It's already the case nevermind sorry for the noise

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants