Skip to content

Prevent Unnecessary Version Bumps in go.mod During Go Version Updates #20781

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

Merged
merged 3 commits into from
May 20, 2025

Conversation

Victorthedev
Copy link
Contributor

This PR addresses issue #20770, where the minikube automation (triggered by make update-golang-version) unnecessarily bumped minor or patch versions in go.mod when updating the Go version. Following Kubernetes' practice, which avoids such bumps in go.mod, this change ensures only the go directive is updated to the stable Go version.

Changes:

  • Added go.mod to the schema map in hack/update/golang_version/update_golang_version.go with a regex (go 1.\d+.\d+) to update the go directive to {{.StableVersion}} (e.g., go 1.24.2).
  • This ensures the automation updates only the go directive without modifying module dependencies, aligning with Kubernetes' go.mod behavior.

Impact:

  • Running make update-golang-version now updates the go directive (e.g., from go 1.22.3 to go 1.24.2) without unintended dependency version bumps.
  • Tested by setting go 1.22.3 in go.mod, running go mod tidy and make update-golang-version, and verifying only the go directive and toolchain changed.

fixes: #20773

This PR addresses issue kubernetes#20770, where the minikube automation (triggered by make `update-golang-version`) unnecessarily bumped minor or patch versions in `go.mod` when updating the Go version. Following Kubernetes' practice, which avoids such bumps in `go.mod`, this change ensures only the go directive is updated to the stable Go version.

**Changes:**
- Added `go.mod` to the schema map in `hack/update/golang_version/update_golang_version.go` with a regex (go 1\.\d+\.\d+) to update the go directive to {{.StableVersion}} (e.g., go 1.24.2).
- This ensures the automation updates only the go directive without modifying module dependencies, aligning with Kubernetes' `go.mod` behavior.

**Impact:**
- Running make `update-golang-version` now updates the go directive (e.g., from go 1.22.3 to go 1.24.2) without unintended dependency version bumps.
- Tested by setting go 1.22.3 in go.mod, running go mod tidy and make update-golang-version, and verifying only the go directive and toolchain changed.

fixes: kubernetes#20773
@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 18, 2025
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 18, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @Victorthedev. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 18, 2025
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

**Description**:
Fixes kubernetes#20773 by updating the automation to pin the `go` directive in `go.mod` to the major.minor Go version (e.g., `1.24.0`) instead of the full version (e.g., `1.24.2`), aligning with Kubernetes’ `go.mod`. This prevents breaking users relying on minikube packages.

**Changes**:
- Modified `hack/update/golang_version/update_golang_version.go` to compute `MajorMinor` version (e.g., `1.24.0`) from `StableVersion`.
- Updated `schema` to set `go.mod`’s `go` directive to `{{.MajorMinor}}`.
- Tested by setting `go 1.23.4`, running `make update-golang-version`, and verifying `go 1.24.0` with no dependency bumps.

**Closes**: kubernetes#20773
@Victorthedev
Copy link
Contributor Author

@medyagh @ComradeProgrammer The second commit fixes issue as it ignore patch version updates in go.mod for go. In the first commit, safe to say i misunderstood the issue at first. Run make update-golang-version

Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

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

thank you very much @Victorthedev do you mind only pushing the change that affect the automation and let the automation to do the change?

@k8s-ci-robot
Copy link
Contributor

Keywords which can automatically close issues and at(@) or hashtag(#) mentions are not allowed in commit messages.

The list of commits with invalid commit messages:

  • aa19542 Prevent Unnecessary Version Bumps in go.mod During Go Version Updates
  • 7bdb800 Pin go.mod to Major.Minor Go Version (e.g., 1.24.0)

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-sigs/prow repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 19, 2025
@Victorthedev
Copy link
Contributor Author

@medyagh I have reverted all files to upstream master except update_golang_version.go, now running make update-golang-version would do the changes

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 19, 2025
@Victorthedev
Copy link
Contributor Author

@medyagh one required check is pending for the PR to be merged

@medyagh
Copy link
Member

medyagh commented May 20, 2025

/lgtm

@medyagh medyagh merged commit 4ebec48 into kubernetes:master May 20, 2025
24 of 25 checks passed
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 20, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: medyagh, Victorthedev

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

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. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make automation not to bump golang patch version in go.mod
4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy