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..74fb074fd613 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 = "Rejected due to low priority" + } 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..f5dec8dfe513 100644 --- a/pkg/minikube/driver/driver_test.go +++ b/pkg/minikube/driver/driver_test.go @@ -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{"unhealthy", "default", "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", "unhealthy", "default", "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..2f54373e018f 100644 --- a/pkg/minikube/registry/global_test.go +++ b/pkg/minikube/registry/global_test.go @@ -97,7 +97,7 @@ func TestGlobalAvailable(t *testing.T) { }, { Name: "unhealthy-foo", - Priority: Unhealthy, + Priority: Default, 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