Skip to content

make default go version the latest stable if unspecified#538

Merged
k8s-ci-robot merged 2 commits intokubernetes:masterfrom
BenTheElder:default-go
Mar 5, 2026
Merged

make default go version the latest stable if unspecified#538
k8s-ci-robot merged 2 commits intokubernetes:masterfrom
BenTheElder:default-go

Conversation

@BenTheElder
Copy link
Member

part of #529, also cleans up stale TODO

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 4, 2026
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 4, 2026
@dims
Copy link
Member

dims commented Mar 4, 2026

/approve
/lgtm
/hold

cc @akhilerm

Ben, please remove hold when ready

@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 Mar 4, 2026
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 4, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BenTheElder, dims

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 Mar 4, 2026
@BenTheElder
Copy link
Member Author

Did a little debugging locally, I think this is good to go.
/hold cancel

@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 Mar 5, 2026
@k8s-ci-robot k8s-ci-robot merged commit 30f16fc into kubernetes:master Mar 5, 2026
7 checks passed
@BenTheElder BenTheElder deleted the default-go branch March 5, 2026 01:04
@akhilerm
Copy link
Member

akhilerm commented Mar 5, 2026

Going through this, just want to do some tests related to how the script works when multiple go versions are involved.


defaultGoVersion := deprecatedDefaultGoVersion
// Respect the default go version if set, otherwise attempt to use current stable go
// with GOTOOLCHAIN we will fetch dynamically the branch / module specific version anyhow.
Copy link
Member

Choose a reason for hiding this comment

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

One small thing here is the go.mod in the branch will always have the .0 version, so when the GOTOOLCHAIN fetches it will be using that, but the go version that we specify is the exact patch version.

Copy link
Member Author

Choose a reason for hiding this comment

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

That should be fine. If .0 doesn't work then we should increase the version we specify.

the only reason I can think not to is if the tests etc pass and the code compiles but somehow there's a problem with some command used only by the publishing bot but not by users and that seems incredibly unlikely, anything we're doing to interact with a go toolchain and these modules needs to also work for the consumers of these libraries, so if it doesn't then we increase the patch version.

If for some reason that thinking turns out to be flawed, we can instead use .go-version from k/k which will be more accurate as we have no mechanism to keep the rules files in sync with the stable branches, we only had a rule to keep the default-go-version in sync on the branch the rules file was in ...

Comment on lines +158 to +160
if len(lines) == 0 {
return "", fmt.Errorf("empty response from go.dev")
}
Copy link
Member

Choose a reason for hiding this comment

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

This check will never be triggered right. Since the strings.Split() will return an array with 1 item, even if the response body is empty.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm yeah. Checking this value is not particularly robust, I generally expect an error code over malformed content or it will be an invalid Go version that will fail later but that's not a huge problem.

This case can also only be triggered in what we currently document as a deprecated mode and would've given you go 1.14 (!)

@BenTheElder
Copy link
Member Author

BenTheElder commented Mar 5, 2026

Maybe instead we should make the default statically 1.21.0 (oldest with GOTOOLCHAIN), and only increase it again when we observe that binary is no longer available or fails to function (unlikely but plausible)

we can test that behavior in k/k without any code changes here (by explicitly setting 1.21.0) and then reconsider.

kubernetes/kubernetes#137421 (comment)

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/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants