From 7aafb2ddcef13e27d808c403eb23b6c616a4aba9 Mon Sep 17 00:00:00 2001 From: nishipy Date: Sat, 15 Jan 2022 11:18:34 -0500 Subject: [PATCH 1/4] Add exit message for too new Kubernetes version --- cmd/minikube/cmd/start.go | 8 ++++++++ pkg/minikube/reason/reason.go | 2 ++ 2 files changed, 10 insertions(+) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 990341c7671c..8d923f78c61b 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -1526,6 +1526,7 @@ func validateKubernetesVersion(old *config.ClusterConfig) { nvs, _ := semver.Make(strings.TrimPrefix(getKubernetesVersion(old), version.VersionPrefix)) oldestVersion := semver.MustParse(strings.TrimPrefix(constants.OldestKubernetesVersion, version.VersionPrefix)) defaultVersion := semver.MustParse(strings.TrimPrefix(constants.DefaultKubernetesVersion, version.VersionPrefix)) + newestVersion := semver.MustParse(strings.TrimPrefix(constants.NewestKubernetesVersion, version.VersionPrefix)) zeroVersion := semver.MustParse(strings.TrimPrefix(constants.NoKubernetesVersion, version.VersionPrefix)) if nvs.Equals(zeroVersion) { @@ -1539,6 +1540,13 @@ func validateKubernetesVersion(old *config.ClusterConfig) { } exitIfNotForced(reason.KubernetesTooOld, "Kubernetes {{.version}} is not supported by this release of minikube", out.V{"version": nvs}) } + if nvs.GT(newestVersion) { + out.WarningT("Specified Kubernetes version {{.specified}} is more than the newest supported version: {{.newest}}", out.V{"specified": nvs, "newest": constants.NewestKubernetesVersion}) + if !viper.GetBool(force) { + out.WarningT("You can force an unsupported Kubernetes version via the --force flag if it exists") + } + exitIfNotForced(reason.KubernetesTooNew, "Kubernetes {{.version}} is not supported by this release of minikube", out.V{"version": nvs}) + } // If the version of Kubernetes has a known issue, print a warning out to the screen if issue := reason.ProblematicK8sVersion(nvs); issue != nil { diff --git a/pkg/minikube/reason/reason.go b/pkg/minikube/reason/reason.go index a15710837480..0b37f7f0eef8 100644 --- a/pkg/minikube/reason/reason.go +++ b/pkg/minikube/reason/reason.go @@ -436,6 +436,8 @@ var ( KubernetesInstallFailedRuntimeNotRunning = Kind{ID: "K8S_INSTALL_FAILED_CONTAINER_RUNTIME_NOT_RUNNING", ExitCode: ExRuntimeNotRunning} // an outdated Kubernetes version was specified for minikube to use KubernetesTooOld = Kind{ID: "K8S_OLD_UNSUPPORTED", ExitCode: ExControlPlaneUnsupported} + // too new Kubernetes version was specified for minikube to use + KubernetesTooNew = Kind{ID: "K8S_OLD_UNSUPPORTED", ExitCode: ExControlPlaneUnsupported} // minikube was unable to safely downgrade installed Kubernetes version KubernetesDowngrade = Kind{ ID: "K8S_DOWNGRADE_UNSUPPORTED", From c3ca1a455534ee6c367c8eae15c83016493a920a Mon Sep 17 00:00:00 2001 From: nishipy Date: Thu, 20 Jan 2022 01:13:29 +0900 Subject: [PATCH 2/4] Add "K8S_NEW_UNSUPPORTED" to exit reason --- pkg/minikube/reason/reason.go | 4 ++-- site/content/en/docs/contrib/errorcodes.en.md | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/minikube/reason/reason.go b/pkg/minikube/reason/reason.go index 0b37f7f0eef8..b2fece0172ac 100644 --- a/pkg/minikube/reason/reason.go +++ b/pkg/minikube/reason/reason.go @@ -436,8 +436,8 @@ var ( KubernetesInstallFailedRuntimeNotRunning = Kind{ID: "K8S_INSTALL_FAILED_CONTAINER_RUNTIME_NOT_RUNNING", ExitCode: ExRuntimeNotRunning} // an outdated Kubernetes version was specified for minikube to use KubernetesTooOld = Kind{ID: "K8S_OLD_UNSUPPORTED", ExitCode: ExControlPlaneUnsupported} - // too new Kubernetes version was specified for minikube to use - KubernetesTooNew = Kind{ID: "K8S_OLD_UNSUPPORTED", ExitCode: ExControlPlaneUnsupported} + // a too new Kubernetes version was specified for minikube to use + KubernetesTooNew = Kind{ID: "K8S_NEW_UNSUPPORTED", ExitCode: ExControlPlaneUnsupported} // minikube was unable to safely downgrade installed Kubernetes version KubernetesDowngrade = Kind{ ID: "K8S_DOWNGRADE_UNSUPPORTED", diff --git a/site/content/en/docs/contrib/errorcodes.en.md b/site/content/en/docs/contrib/errorcodes.en.md index 4b26b4a3ccaa..ed618ccc6745 100644 --- a/site/content/en/docs/contrib/errorcodes.en.md +++ b/site/content/en/docs/contrib/errorcodes.en.md @@ -537,6 +537,9 @@ minikube failed to update the Kubernetes cluster because the container runtime w "K8S_OLD_UNSUPPORTED" (Exit code ExControlPlaneUnsupported) an outdated Kubernetes version was specified for minikube to use +"K8S_NEW_UNSUPPORTED" (Exit code ExControlPlaneUnsupported) +a too new Kubernetes version was specified for minikube to use + "K8S_DOWNGRADE_UNSUPPORTED" (Exit code ExControlPlaneUnsupported) minikube was unable to safely downgrade installed Kubernetes version From dc1b226562ef681fd4f74e6d36fbb97f6f86e044 Mon Sep 17 00:00:00 2001 From: nishipy <41185206+nishipy@users.noreply.github.com> Date: Wed, 26 Jan 2022 15:32:09 +0900 Subject: [PATCH 3/4] Update cmd/minikube/cmd/start.go Co-authored-by: Sharif Elgamal --- cmd/minikube/cmd/start.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 8d923f78c61b..ce9cbc8248d1 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -1541,7 +1541,7 @@ func validateKubernetesVersion(old *config.ClusterConfig) { exitIfNotForced(reason.KubernetesTooOld, "Kubernetes {{.version}} is not supported by this release of minikube", out.V{"version": nvs}) } if nvs.GT(newestVersion) { - out.WarningT("Specified Kubernetes version {{.specified}} is more than the newest supported version: {{.newest}}", out.V{"specified": nvs, "newest": constants.NewestKubernetesVersion}) + out.WarningT("Specified Kubernetes version {{.specified}} is newer than the newest supported version: {{.newest}}", out.V{"specified": nvs, "newest": constants.NewestKubernetesVersion}) if !viper.GetBool(force) { out.WarningT("You can force an unsupported Kubernetes version via the --force flag if it exists") } From 9da7049f8ac7b3d33ca6b699da2c99d4f6066653 Mon Sep 17 00:00:00 2001 From: nishipy Date: Sun, 30 Jan 2022 07:27:23 -0500 Subject: [PATCH 4/4] Currently, no warn or exit are there even if user specifies any version newer than newestKubernetesVersion. This fixes the flow as follows: if not --force: - Warn but do NOT exit for newer minor version and patch version - Warn and Exit for newer major version if --force: Warn but try anyways --- cmd/minikube/cmd/start.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index ce9cbc8248d1..d6407944ebf5 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -1533,19 +1533,22 @@ func validateKubernetesVersion(old *config.ClusterConfig) { klog.Infof("No Kuberentes version set for minikube, setting Kubernetes version to %s", constants.NoKubernetesVersion) return } - if nvs.LT(oldestVersion) { - out.WarningT("Specified Kubernetes version {{.specified}} is less than the oldest supported version: {{.oldest}}", out.V{"specified": nvs, "oldest": constants.OldestKubernetesVersion}) + if nvs.Major > newestVersion.Major { + out.WarningT("Specified Major version of Kubernetes {{.specifiedMajor}} is newer than the newest supported Major version: {{.newestMajor}}", out.V{"specifiedMajor": nvs.Major, "newestMajor": newestVersion.Major}) if !viper.GetBool(force) { out.WarningT("You can force an unsupported Kubernetes version via the --force flag") } - exitIfNotForced(reason.KubernetesTooOld, "Kubernetes {{.version}} is not supported by this release of minikube", out.V{"version": nvs}) + exitIfNotForced(reason.KubernetesTooNew, "Kubernetes {{.version}} is not supported by this release of minikube", out.V{"version": nvs}) } if nvs.GT(newestVersion) { out.WarningT("Specified Kubernetes version {{.specified}} is newer than the newest supported version: {{.newest}}", out.V{"specified": nvs, "newest": constants.NewestKubernetesVersion}) + } + if nvs.LT(oldestVersion) { + out.WarningT("Specified Kubernetes version {{.specified}} is less than the oldest supported version: {{.oldest}}", out.V{"specified": nvs, "oldest": constants.OldestKubernetesVersion}) if !viper.GetBool(force) { - out.WarningT("You can force an unsupported Kubernetes version via the --force flag if it exists") + out.WarningT("You can force an unsupported Kubernetes version via the --force flag") } - exitIfNotForced(reason.KubernetesTooNew, "Kubernetes {{.version}} is not supported by this release of minikube", out.V{"version": nvs}) + exitIfNotForced(reason.KubernetesTooOld, "Kubernetes {{.version}} is not supported by this release of minikube", out.V{"version": nvs}) } // If the version of Kubernetes has a known issue, print a warning out to the screen