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

Setup a consistent way to manage go version #17857

Open
ahrtr opened this issue Apr 23, 2024 · 6 comments
Open

Setup a consistent way to manage go version #17857

ahrtr opened this issue Apr 23, 2024 · 6 comments
Assignees

Comments

@ahrtr
Copy link
Member

ahrtr commented Apr 23, 2024

What would you like to be added?

Currently there are multiple places setting the go versions, for examples,

We should set up a consistent way to manage go version. There should be only one source of truth for the go&toolchain version.

One problem is that if a dependency sets a higher go or toolchain version, then when running scripts/fix.sh will automatically update the go & toolchain version in our go.mod files. Refer to https://github.com/etcd-io/etcd/pull/17841/files#r1575344566

References:

cc @fuweid @henrybear327 @ivanvc @jmhbnz @MadhavJivrajani @serathius

Why is this needed?

Setup consistent way to manage go version

@MadhavJivrajani
Copy link
Contributor

One problem is that if a dependency sets a higher go or toolchain version, then when running scripts/fix.sh will automatically update the go & toolchain version in our go.mod files.

We are trying to be more careful about this situation in Kubernetes (ref: kubernetes/kubernetes#123744).

One thing we should keep in mind here also is that if dependabot bumps the go directive of the root go.mod and we don't reflect that change in the .go-version file then it could be problematic for reasons similar to kubernetes/kubernetes#123744, if that happens, we are in a situation where:

  • We build with a go version that is in .go-version, because the release GH action uses that as source of truth.
  • However, if the go directive in go.mod is newer, go will default the values of GODEBUG based on the value of the go directive (see https://go.dev/doc/godebug). This will alter the runtime behaviour because the user might expect behaviour similar to whatever the go directive is, but the actual behaviour is that of .go-version.

In Kubernetes we added a pre-submit check to catch such accidental bumps if they occur: kubernetes/kube-openapi#467

@ahrtr
Copy link
Member Author

ahrtr commented Apr 24, 2024

In Kubernetes we added a pre-submit check to catch such accidental bumps if they occur: kubernetes/kube-openapi#467

Thanks @MadhavJivrajani

I think we should do similar check for all etcd branches: including release-3.4, release-3.4 and main.

The other potential enhancement is to automatically populate the go versions for the go and toolchain lines in all go.mod (and go.sum) files based on the .go-version file.

@MadhavJivrajani
Copy link
Contributor

I have some ideas on how we can go about doing this. Will create a PR and we can discuss there!

@ahrtr
Copy link
Member Author

ahrtr commented May 8, 2024

@ahrtr
Copy link
Member Author

ahrtr commented May 8, 2024

I think we also need to backport the changes to both 3.5 and 3.4

@ahrtr
Copy link
Member Author

ahrtr commented May 8, 2024

We should follow the same rule to manage go version for all repositories under etcd-io. Note we only require users to depend on a minor version supported by golang team, i.e. 1.21, but we don't force users to depend on a patch version, i.e. 1.21.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants