From deead301f20ca5aed8bda973346db0f4ba746218 Mon Sep 17 00:00:00 2001 From: serhatcetinkaya Date: Sun, 14 Jul 2019 19:29:08 +0300 Subject: [PATCH 1/5] start: compare specified kubernetes version with oldest supported version --- cmd/minikube/cmd/start.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 7920d575b605..981dbd7af144 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -679,6 +679,20 @@ func validateKubernetesVersions(old *cfg.Config) (string, bool) { return nv, isUpgrade } + oldestVersion, err := semver.Make(strings.TrimPrefix(constants.OldestKubernetesVersion, version.VersionPrefix)) + if err != nil { + exit.WithCode(exit.Data, "Unable to parse oldest Kubernetes version from constants: %v", err) + } + + superOldVersionLimit := semver.Version{Major: 1, Minor: 9, Patch: 0} + if nvs.LT(superOldVersionLimit) { + exit.WithCode(exit.Data, "Specified Kubernetes version is not supported in minikube: %q", rawVersion) + } + + if nvs.LT(oldestVersion) { + console.ErrT(console.Conflict, "Specified Kubernetes version {{.specified}} is less than the oldest supported version: {{.oldest}}", console.Arg{"specified": nvs, "oldest": constants.OldestKubernetesVersion}) + } + ovs, err := semver.Make(strings.TrimPrefix(old.KubernetesConfig.KubernetesVersion, version.VersionPrefix)) if err != nil { glog.Errorf("Error parsing old version %q: %v", old.KubernetesConfig.KubernetesVersion, err) From 2230a52aa021f19014a18b366612616850fda1c9 Mon Sep 17 00:00:00 2001 From: serhatcetinkaya Date: Sun, 1 Sep 2019 20:30:07 +0300 Subject: [PATCH 2/5] start: check force flag while comparing specified version --- cmd/minikube/cmd/start.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 51a905a927c1..2b07e6fc3fb6 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -853,13 +853,13 @@ func validateKubernetesVersions(old *cfg.Config) (string, bool) { exit.WithCode(exit.Data, "Unable to parse oldest Kubernetes version from constants: %v", err) } - superOldVersionLimit := semver.Version{Major: 1, Minor: 9, Patch: 0} - if nvs.LT(superOldVersionLimit) { - exit.WithCode(exit.Data, "Specified Kubernetes version is not supported in minikube: %q", rawVersion) - } - if nvs.LT(oldestVersion) { console.ErrT(console.Conflict, "Specified Kubernetes version {{.specified}} is less than the oldest supported version: {{.oldest}}", console.Arg{"specified": nvs, "oldest": constants.OldestKubernetesVersion}) + if viper.GetBool(force) { + out.WarningT("Kubernetes {{.version}} is not supported by this release of minikube", console.Arg{"version": nvs}) + } else { + exit.WithCode(exit.Data, "Sorry, Kubernetes {{.version}} is not supported by this release of minikube", console.Arg{"version": nvs}) + } } ovs, err := semver.Make(strings.TrimPrefix(old.KubernetesConfig.KubernetesVersion, version.VersionPrefix)) From 0b829cc22d8b94d1b739b5aae62b1778680170ef Mon Sep 17 00:00:00 2001 From: serhatcetinkaya Date: Sun, 1 Sep 2019 20:46:44 +0300 Subject: [PATCH 3/5] fix warnings --- cmd/minikube/cmd/start.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 2b07e6fc3fb6..7df98b1f4799 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -854,11 +854,11 @@ func validateKubernetesVersions(old *cfg.Config) (string, bool) { } if nvs.LT(oldestVersion) { - console.ErrT(console.Conflict, "Specified Kubernetes version {{.specified}} is less than the oldest supported version: {{.oldest}}", console.Arg{"specified": nvs, "oldest": constants.OldestKubernetesVersion}) + 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("Kubernetes {{.version}} is not supported by this release of minikube", console.Arg{"version": nvs}) + out.WarningT("Kubernetes {{.version}} is not supported by this release of minikube", out.V{"version": nvs}) } else { - exit.WithCode(exit.Data, "Sorry, Kubernetes {{.version}} is not supported by this release of minikube", console.Arg{"version": nvs}) + exit.WithCode(exit.Data, "Sorry, Kubernetes {{.version}} is not supported by this release of minikube", out.V{"version": nvs}) } } From 14b1d84474163fccb77947802d08e092f728d15f Mon Sep 17 00:00:00 2001 From: serhatcetinkaya Date: Sun, 1 Sep 2019 20:50:44 +0300 Subject: [PATCH 4/5] start.go rename exit.WithCode with exit.WithCodeT --- cmd/minikube/cmd/start.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 7df98b1f4799..95e754135d8c 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -850,7 +850,7 @@ func validateKubernetesVersions(old *cfg.Config) (string, bool) { oldestVersion, err := semver.Make(strings.TrimPrefix(constants.OldestKubernetesVersion, version.VersionPrefix)) if err != nil { - exit.WithCode(exit.Data, "Unable to parse oldest Kubernetes version from constants: %v", err) + exit.WithCodeT(exit.Data, "Unable to parse oldest Kubernetes version from constants: %v", err) } if nvs.LT(oldestVersion) { @@ -858,7 +858,7 @@ func validateKubernetesVersions(old *cfg.Config) (string, bool) { if viper.GetBool(force) { out.WarningT("Kubernetes {{.version}} is not supported by this release of minikube", out.V{"version": nvs}) } else { - exit.WithCode(exit.Data, "Sorry, Kubernetes {{.version}} is not supported by this release of minikube", out.V{"version": nvs}) + exit.WithCodeT(exit.Data, "Sorry, Kubernetes {{.version}} is not supported by this release of minikube", out.V{"version": nvs}) } } From 23cc018bbf129161a815c11a7f57c07c55595b90 Mon Sep 17 00:00:00 2001 From: serhatcetinkaya Date: Sun, 1 Sep 2019 21:01:32 +0300 Subject: [PATCH 5/5] start.go make err type usable for exit.withCodeT --- 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 95e754135d8c..79305427b1eb 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -850,7 +850,7 @@ func validateKubernetesVersions(old *cfg.Config) (string, bool) { oldestVersion, err := semver.Make(strings.TrimPrefix(constants.OldestKubernetesVersion, version.VersionPrefix)) if err != nil { - exit.WithCodeT(exit.Data, "Unable to parse oldest Kubernetes version from constants: %v", err) + exit.WithCodeT(exit.Data, "Unable to parse oldest Kubernetes version from constants: {{.error}}", out.V{"error": err}) } if nvs.LT(oldestVersion) {