diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 08b9b0a21247..a7401affd042 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -27,6 +27,7 @@ import ( "os/user" "regexp" "runtime" + "sort" "strings" "github.com/blang/semver" @@ -593,7 +594,11 @@ func selectDriver(existing *config.ClusterConfig) (registry.DriverState, []regis pick, alts, rejects := driver.Suggest(choices) if pick.Name == "" { out.Step(style.ThumbsDown, "Unable to pick a default driver. Here is what was considered, in preference order:") - for _, r := range rejects { + altsAndRejects := append(alts, rejects...) + sort.Slice(altsAndRejects, func(i, j int) bool { + return altsAndRejects[i].Priority > altsAndRejects[j].Priority + }) + for _, r := range altsAndRejects { out.Infof("{{ .name }}: {{ .rejection }}", out.V{"name": r.Name, "rejection": r.Rejection}) } exit.Message(reason.DrvNotDetected, "No possible driver was detected. Try specifying --driver, or see https://minikube.sigs.k8s.io/docs/start/") diff --git a/pkg/minikube/driver/driver.go b/pkg/minikube/driver/driver.go index 4053a9dfef3a..b2c9b944d85b 100644 --- a/pkg/minikube/driver/driver.go +++ b/pkg/minikube/driver/driver.go @@ -279,7 +279,11 @@ func Suggest(options []registry.DriverState) (registry.DriverState, []registry.D continue } - ds.Rejection = fmt.Sprintf("%s is preferred", pick.Name) + if pick.Name == "" { + ds.Rejection = fmt.Sprintf("Not selected: %s must be specified explicitly using --driver", ds.Name) + } else { + ds.Rejection = fmt.Sprintf("%s is preferred", pick.Name) + } alternates = append(alternates, ds) } } diff --git a/pkg/minikube/driver/driver_test.go b/pkg/minikube/driver/driver_test.go index b4fac014eb52..ff938855b956 100644 --- a/pkg/minikube/driver/driver_test.go +++ b/pkg/minikube/driver/driver_test.go @@ -119,7 +119,7 @@ func TestSuggest(t *testing.T) { { def: registry.DriverDef{ Name: "unhealthy", - Priority: registry.Default, + Priority: registry.Deprecated, Status: func() registry.State { return registry.State{Installed: true, Healthy: false} }, }, choices: []string{"unhealthy"}, @@ -133,7 +133,7 @@ func TestSuggest(t *testing.T) { Priority: registry.Discouraged, Status: func() registry.State { return registry.State{Installed: true, Healthy: true} }, }, - choices: []string{"discouraged", "unhealthy"}, + choices: []string{"unhealthy", "discouraged"}, pick: "", alts: []string{"discouraged"}, rejects: []string{"unhealthy"}, @@ -144,7 +144,7 @@ func TestSuggest(t *testing.T) { Priority: registry.Default, Status: func() registry.State { return registry.State{Installed: true, Healthy: true} }, }, - choices: []string{"default", "discouraged", "unhealthy"}, + choices: []string{"default", "unhealthy", "discouraged"}, pick: "default", alts: []string{"discouraged"}, rejects: []string{"unhealthy"}, @@ -155,7 +155,7 @@ func TestSuggest(t *testing.T) { Priority: registry.Preferred, Status: func() registry.State { return registry.State{Installed: true, Healthy: true} }, }, - choices: []string{"preferred", "default", "discouraged", "unhealthy"}, + choices: []string{"preferred", "default", "unhealthy", "discouraged"}, pick: "preferred", alts: []string{"default", "discouraged"}, rejects: []string{"unhealthy"}, diff --git a/pkg/minikube/registry/global.go b/pkg/minikube/registry/global.go index 7ffc3d5d94de..95c185460b25 100644 --- a/pkg/minikube/registry/global.go +++ b/pkg/minikube/registry/global.go @@ -110,10 +110,6 @@ func Available(vm bool) []DriverState { klog.Infof("%s priority: %d, state: %+v", d.Name, d.Priority, s) priority := d.Priority - if !s.Healthy { - priority = Unhealthy - } - if vm { if IsVM(d.Name) { sts = append(sts, DriverState{Name: d.Name, Priority: priority, State: s}) diff --git a/pkg/minikube/registry/global_test.go b/pkg/minikube/registry/global_test.go index 9cb01a1e3599..40e17c7005aa 100644 --- a/pkg/minikube/registry/global_test.go +++ b/pkg/minikube/registry/global_test.go @@ -73,7 +73,7 @@ func TestGlobalAvailable(t *testing.T) { bar := DriverDef{ Name: "healthy-bar", - Priority: Default, + Priority: Preferred, Status: func() State { return State{Healthy: true} }, } if err := Register(bar); err != nil { @@ -82,7 +82,7 @@ func TestGlobalAvailable(t *testing.T) { foo := DriverDef{ Name: "unhealthy-foo", - Priority: Default, + Priority: Fallback, Status: func() State { return State{Healthy: false} }, } if err := Register(foo); err != nil { @@ -92,12 +92,12 @@ func TestGlobalAvailable(t *testing.T) { expected := []DriverState{ { Name: "healthy-bar", - Priority: Default, + Priority: Preferred, State: State{Healthy: true}, }, { Name: "unhealthy-foo", - Priority: Unhealthy, + Priority: Fallback, State: State{Healthy: false}, }, } diff --git a/pkg/minikube/registry/registry.go b/pkg/minikube/registry/registry.go index 3d4b065d1083..bc50bd84134d 100644 --- a/pkg/minikube/registry/registry.go +++ b/pkg/minikube/registry/registry.go @@ -33,8 +33,6 @@ const ( Unknown Priority = iota // Obsolete is when a driver has been removed Obsolete - // Unhealthy is when a driver does not pass health checks - Unhealthy // Experimental is when a driver is not officially supported because it's still experimental Experimental // Discouraged is when a driver has caveats that preclude it's recommendation