From 58dedbbb189610242aead3e0a6f3d99357e7483d Mon Sep 17 00:00:00 2001 From: Yanshu Zhao Date: Sat, 2 Jan 2021 08:35:02 +0000 Subject: [PATCH 1/2] Delete the existing cluster if guest driver mismatch --- cmd/minikube/cmd/start.go | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 5e40239fdc..40058f5298 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -668,16 +668,29 @@ func validateSpecifiedDriver(existing *config.ClusterConfig) { return } + out.WarningT("Start deleting cluster {{.name}} with delete-on-failure flag set", out.V{"name": existing.Name}) + if viper.GetBool(deleteOnFailure) { + // Start failed, delete the cluster + profile, err := config.LoadProfile(existing.Name) + if err != nil { + out.ErrT(style.Meh, `"{{.name}}" profile does not exist, trying anyways.`, out.V{"name": existing.Name}) + } + + err = deleteProfile(profile) + if err != nil { + out.WarningT("Failed to delete cluster {{.name}}.", out.V{"name": existing.Name}) + } + } + exit.Advice( reason.GuestDrvMismatch, - `The existing "{{.name}}" cluster was created using the "{{.old}}" driver, which is incompatible with requested "{{.new}}" driver.`, - "Delete the existing '{{.name}}' cluster using: '{{.delcommand}}', or start the existing '{{.name}}' cluster using: '{{.command}} --driver={{.old}}'", + `The existing "{{.name}}" cluster was created using the "{{.old}}" driver, which is incompatible with requested "{{.new}}" driver. Deleted the existing '{{.name}}' cluster.`, + "Start the new '{{.name}}' cluster using: '{{.command}} --driver={{.new}}'", out.V{ - "name": existing.Name, - "new": requested, - "old": old, - "command": mustload.ExampleCmd(existing.Name, "start"), - "delcommand": mustload.ExampleCmd(existing.Name, "delete"), + "name": existing.Name, + "new": requested, + "old": old, + "command": mustload.ExampleCmd(existing.Name, "start"), }, ) } From 7fa6d545d78f068d5d0aa022213435780022c996 Mon Sep 17 00:00:00 2001 From: Yanshu Zhao Date: Mon, 4 Jan 2021 07:31:41 +0000 Subject: [PATCH 2/2] Change warning --- cmd/minikube/cmd/start.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 40058f5298..1c1d7b6c6a 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -668,7 +668,7 @@ func validateSpecifiedDriver(existing *config.ClusterConfig) { return } - out.WarningT("Start deleting cluster {{.name}} with delete-on-failure flag set", out.V{"name": existing.Name}) + out.WarningT("Deleting existing cluster {{.name}} with different driver {{.driver_name}} due to --delete-on-failure flag set by the user. ", out.V{"name": existing.Name, "driver_name": old}) if viper.GetBool(deleteOnFailure) { // Start failed, delete the cluster profile, err := config.LoadProfile(existing.Name) @@ -684,13 +684,14 @@ func validateSpecifiedDriver(existing *config.ClusterConfig) { exit.Advice( reason.GuestDrvMismatch, - `The existing "{{.name}}" cluster was created using the "{{.old}}" driver, which is incompatible with requested "{{.new}}" driver. Deleted the existing '{{.name}}' cluster.`, - "Start the new '{{.name}}' cluster using: '{{.command}} --driver={{.new}}'", + `The existing "{{.name}}" cluster was created using the "{{.old}}" driver, which is incompatible with requested "{{.new}}" driver.`, + "Delete the existing '{{.name}}' cluster using: '{{.delcommand}}', or start the existing '{{.name}}' cluster using: '{{.command}} --driver={{.old}}'", out.V{ - "name": existing.Name, - "new": requested, - "old": old, - "command": mustload.ExampleCmd(existing.Name, "start"), + "name": existing.Name, + "new": requested, + "old": old, + "command": mustload.ExampleCmd(existing.Name, "start"), + "delcommand": mustload.ExampleCmd(existing.Name, "delete"), }, ) }