Repository: kubernetes/minikube
Pull request #16915 (2023-07-19 20:45:50)

Release v1.31.1

k8s-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes/minikube/pull/16915#" title="Author self-approved">spowelljr</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes%2Fminikube).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubernetes/minikube/blob/master/OWNERS)~~ [spowelljr]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1d514e530..7e496954b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,27 @@
 # Release Notes
 
+## Version 1.31.1 - 2023-07-20
+
+* cni: Fix regression in auto selection [#16912](https://github.com/kubernetes/minikube/pull/16912)
+
+For a more detailed changelog, see [CHANGELOG.md](https://github.com/kubernetes/minikube/blob/master/CHANGELOG.md).
+
+Thank you to our contributors for this release!
+
+- Jeff MAURY
+- Medya Ghazizadeh
+- Steven Powell
+
+Thank you to our triage members for this release!
+
+- afbjorklund (5 comments)
+- torenware (5 comments)
+- mprimeaux (3 comments)
+- prezha (3 comments)
+- spowelljr (1 comments)
+
+Check out our [contributions leaderboard](https://minikube.sigs.k8s.io/docs/contrib/leaderboard/v1.31.1/) for this release!
+
 ## Version 1.31.0 - 2023-07-18
 
 Features:
diff --git a/Makefile b/Makefile
index 31cb83301..db4f50a67 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@
 # Bump these on release - and please check ISO_VERSION for correctness.
 VERSION_MAJOR ?= 1
 VERSION_MINOR ?= 31
-VERSION_BUILD ?= 0
+VERSION_BUILD ?= 1
 RAW_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_BUILD)
 VERSION ?= v$(RAW_VERSION)
 
diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go
index 4fa32dd2f..b9f8de22f 100644
--- a/cmd/minikube/cmd/start.go
+++ b/cmd/minikube/cmd/start.go
@@ -426,11 +426,29 @@ func validateBuiltImageVersion(r command.Runner, driverName string) {
 		return
 	}
 
-	if versionDetails.MinikubeVersion != version.GetVersion() {
+	if !imageMatchesBinaryVersion(versionDetails.MinikubeVersion, version.GetVersion()) {
 		out.WarningT("Image was not built for the current minikube version. To resolve this you can delete and recreate your minikube cluster using the latest images. Expected minikube version: {{.imageMinikubeVersion}} -> Actual minikube version: {{.minikubeVersion}}", out.V{"imageMinikubeVersion": versionDetails.MinikubeVersion, "minikubeVersion": version.GetVersion()})
 	}
 }
 
+func imageMatchesBinaryVersion(imageVersion, binaryVersion string) bool {
+	// the map below is used to map the binary version to the version the image expects
+	// this is usually done when a patch version is released but a new ISO/Kicbase is not needed
+	// that way a version mismatch warning won't be thrown
+	//
+	// ex.
+	// the v1.31.0 and v1.31.1 minikube binaries both use v1.31.0 ISO & Kicbase
+	// to prevent the v1.31.1 binary from throwing a version mismatch warning we use the map to use change the binary version used in the comparison
+
+	mappedVersions := map[string]string{
+		"v1.31.1": "v1.31.0",
+	}
+	if v, ok := mappedVersions[binaryVersion]; ok {
+		binaryVersion = v
+	}
+	return binaryVersion == imageVersion
+}
+
 func startWithDriver(cmd *cobra.Command, starter node.Starter, existing *config.ClusterConfig) (*kubeconfig.Settings, error) {
 	kubeconfig, err := node.Start(starter, true)
 	if err != nil {


Test patch:
diff --git a/cmd/minikube/cmd/start_test.go b/cmd/minikube/cmd/start_test.go
index d05e91ed8..2eed76a7f 100644
--- a/cmd/minikube/cmd/start_test.go
+++ b/cmd/minikube/cmd/start_test.go
@@ -840,3 +840,23 @@ func TestValidateStaticIP(t *testing.T) {
 		}
 	}
 }
+
+func TestImageMatchesBinaryVersion(t *testing.T) {
+	tests := []struct {
+		imageVersion  string
+		binaryVersion string
+		versionMatch  bool
+	}{
+		{"v1.17.0", "v1.17.0", true},
+		{"v1.17.0", "v1.20.0", false},
+		{"v1.31.0", "v1.31.1", true},
+		{"v1.31.1", "v1.31.0", false},
+	}
+
+	for _, tc := range tests {
+		got := imageMatchesBinaryVersion(tc.imageVersion, tc.binaryVersion)
+		if got != tc.versionMatch {
+			t.Errorf("imageMatchesBinaryVersion(%s, %s) = %t; want = %t", tc.imageVersion, tc.binaryVersion, got, tc.versionMatch)
+		}
+	}
+}