Skip to content

fix: conslidate use of masterminds semver across the codebase#8399

Merged
awesomenix merged 1 commit intomainfrom
nishp/usemasterminds
Apr 24, 2026
Merged

fix: conslidate use of masterminds semver across the codebase#8399
awesomenix merged 1 commit intomainfrom
nishp/usemasterminds

Conversation

@awesomenix
Copy link
Copy Markdown
Contributor

We seem to be using some old library for semver, consolidate use of masterminds semver across the codebase

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Consolidates semantic version parsing/comparison to use github.com/Masterminds/semver/v3 across the main module, e2e, and aks-node-controller, replacing remaining usage of github.com/blang/semver (and a lingering v1 Masterminds import).

Changes:

  • Replace blang/semver usage with Masterminds/semver/v3 and update comparisons to v3 APIs.
  • Harden version-handling helpers to skip/return on parse errors instead of ignoring them.
  • Update module dependencies (go.mod/go.sum) in root, e2e, and aks-node-controller accordingly.

Reviewed changes

Copilot reviewed 10 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/agent/utils.go Switch IsKubernetesVersionGe to Masterminds semver v3 parsing/comparison.
pkg/agent/datamodel/versions.go Replace multiple semver operations (filtering/sorting/comparisons) with v3 APIs and add parse-error handling.
go.mod Drop github.com/blang/semver requirement.
go.sum Remove github.com/blang/semver checksums.
e2e/validators.go Use v3 semver parsing for runc version validation.
e2e/toolkit/k8s.go Fix semver import path to /v3.
e2e/scenario_win_test.go Fix semver import path to /v3.
e2e/node_config.go Fix semver import path to /v3.
e2e/go.mod Replace blang/semver with Masterminds/semver/v3.
e2e/go.sum Remove blang/semver and Masterminds semver v1 entries.
aks-node-controller/helpers/utils.go Switch IsKubernetesVersionGe to v3 parsing/comparison.
aks-node-controller/go.mod Replace blang/semver with Masterminds/semver/v3 (and tidy yaml dep).
aks-node-controller/go.sum Remove blang/semver checksums.

Comment thread e2e/validators.go
Comment on lines 1254 to +1260
require.Lenf(s.T, versions, 1, "Expected exactly one version for moby-runc but got %d", len(versions))
// check if versions[0] is great than or equal to 1.2.0
// check semantic version
semver, err := semver.ParseTolerant(versions[0])
parsedVersion, err := semver.NewVersion(versions[0])
require.NoError(s.T, err, "failed to parse semver from moby-runc version")
require.GreaterOrEqual(s.T, int(semver.Major), 1, "expected moby-runc major version to be at least 1, got %d", semver.Major)
require.GreaterOrEqual(s.T, int(semver.Minor), 2, "expected moby-runc minor version to be at least 2, got %d", semver.Minor)
require.GreaterOrEqual(s.T, int(parsedVersion.Major()), 1, "expected moby-runc major version to be at least 1, got %d", parsedVersion.Major())
require.GreaterOrEqual(s.T, int(parsedVersion.Minor()), 2, "expected moby-runc minor version to be at least 2, got %d", parsedVersion.Minor())
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

ValidateRuncVersion claims to check that the version is >= 1.2.0, but the current assertions only check Major >= 1 and Minor >= 2. This will incorrectly fail for versions like 2.0.0 (which is >= 1.2.0) and can also pass versions like 1.2.0-alpha depending on intent. Consider using a semver constraint check (e.g., ">= 1.2.0") against the parsed version instead of separate major/minor comparisons.

Copilot uses AI. Check for mistakes.
@awesomenix awesomenix merged commit b30beb6 into main Apr 24, 2026
34 of 39 checks passed
@awesomenix awesomenix deleted the nishp/usemasterminds branch April 24, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants