提交 6a5fbbac 编写于 作者: J Jose Donizetti 提交者: Sharif Elgamal

Warn if hyperkit version is old (#4691)

* Add warn if hyperkit driver version is old

* Add hyperkit upgrade documentation

* Improve kvm/hyperkit upgrade warn message

* Move validateDriverVersion to before downloading ISO

* Change executable to use constants
上级 bcf35978
......@@ -210,8 +210,10 @@ var startCmd = &cobra.Command{
// runStart handles the executes the flow of "minikube start"
func runStart(cmd *cobra.Command, args []string) {
out.T(out.Happy, "minikube {{.version}} on {{.os}} ({{.arch}})", out.V{"version": version.GetVersion(), "os": runtime.GOOS, "arch": runtime.GOARCH})
validateConfig()
validateUser()
validateDriverVersion(viper.GetString(vmDriver))
k8sVersion, isUpgrade := getKubernetesVersion()
config, err := generateConfig(cmd, k8sVersion)
......@@ -235,7 +237,6 @@ func runStart(cmd *cobra.Command, args []string) {
exit.WithError("Failed to save config", err)
}
validateDriverVersion(viper.GetString(vmDriver))
// exits here in case of --download-only option.
handleDownloadOnly(&cacheGroup, k8sVersion)
mRunner, preExists, machineAPI, host := startMachine(&config)
......@@ -904,39 +905,60 @@ func saveConfig(clusterConfig *cfg.Config) error {
}
func validateDriverVersion(vmDriver string) {
if vmDriver == constants.DriverKvm2 {
cmd := exec.Command("docker-machine-driver-kvm2", "version")
output, err := cmd.Output()
var (
driverExecutable string
driverDocumentation string
)
switch vmDriver {
case constants.DriverKvm2:
driverExecutable = fmt.Sprintf("docker-machine-driver-%s", constants.DriverKvm2)
driverDocumentation = fmt.Sprintf("%s#%s", constants.DriverDocumentation, "kvm2-upgrade")
case constants.DriverHyperkit:
driverExecutable = fmt.Sprintf("docker-machine-driver-%s", constants.DriverHyperkit)
driverDocumentation = fmt.Sprintf("%s#%s", constants.DriverDocumentation, "hyperkit-upgrade")
default: // driver doesn't support version
return
}
// we don't want to fail if an error was returned,
// libmachine has a nice message for the user if the driver isn't present
if err != nil {
out.WarningT("Error checking driver version: {{.error}}", out.V{"error": err})
return
}
cmd := exec.Command(driverExecutable, "version")
output, err := cmd.Output()
v := extractVMDriverVersion(string(output))
// we don't want to fail if an error was returned,
// libmachine has a nice message for the user if the driver isn't present
if err != nil {
out.WarningT("Error checking driver version: {{.error}}", out.V{"error": err})
return
}
// if the driver doesn't have return any version, it is really old, we force a upgrade.
if len(v) == 0 {
exit.WithCodeT(exit.Failure, "Please upgrade the 'docker-machine-driver-kvm2'. {{.documentation_url}}", out.V{"documentation_url": constants.KVMDocumentation})
}
v := extractVMDriverVersion(string(output))
vmDriverVersion, err := semver.Make(v)
if err != nil {
out.WarningT("Error parsing vmDriver version: {{.error}}", out.V{"error": err})
return
}
// if the driver doesn't have return any version, it is really old, we force a upgrade.
if len(v) == 0 {
exit.WithCodeT(
exit.Failure,
"Please upgrade the '{{.driver_executable}}'. {{.documentation_url}}",
out.V{"driver_executable": driverExecutable, "documentation_url": driverDocumentation},
)
}
minikubeVersion, err := version.GetSemverVersion()
if err != nil {
out.WarningT("Error parsing minukube version: {{.error}}", out.V{"error": err})
return
}
vmDriverVersion, err := semver.Make(v)
if err != nil {
out.WarningT("Error parsing vmDriver version: {{.error}}", out.V{"error": err})
return
}
if vmDriverVersion.LT(minikubeVersion) {
out.WarningT("The 'docker-machine-driver-kvm2' version is old. Please consider upgrading. {{.documentation_url}}", out.V{"documentation_url": constants.KVMDocumentation})
}
minikubeVersion, err := version.GetSemverVersion()
if err != nil {
out.WarningT("Error parsing minukube version: {{.error}}", out.V{"error": err})
return
}
if vmDriverVersion.LT(minikubeVersion) {
out.WarningT(
"There's a new version for '{{.driver_executable}}'. Please consider upgrading. {{.documentation_url}}",
out.V{"driver_executable": driverExecutable, "documentation_url": driverDocumentation},
)
}
}
......
......@@ -143,6 +143,13 @@ or, to use hyperkit as a default driver for minikube:
minikube config set vm-driver hyperkit
```
### Hyperkit upgrade
```shell
curl -LO https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-hyperkit \
&& sudo install -o root -g wheel -m 4755 docker-machine-driver-hyperkit /usr/local/bin/
```
### Hyperkit troubleshoot
Make sure you are running the lastest version of your driver.
......
......@@ -423,6 +423,6 @@ const (
)
const (
// KVMDocumentation the documentation of the KVM driver
KVMDocumentation = "https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#kvm2-driver"
// DriverDocumentation the documentation of the KVM driver
DriverDocumentation = "https://github.com/kubernetes/minikube/blob/master/docs/drivers.md"
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册