Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Health check previously configured driver & exit if not installed #5840

Merged
merged 7 commits into from
Nov 11, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/minikube/driver/driver_test.go
Original file line number Diff line number Diff line change
@@ -105,7 +105,7 @@ func TestChoices(t *testing.T) {
Priority: registry.Discouraged,
Status: func() registry.State { return registry.State{Installed: true, Healthy: true} },
},
choices: []string{"unhealthy", "discouraged"},
choices: []string{"discouraged", "unhealthy"},
pick: "",
alts: []string{"discouraged"},
},
@@ -115,7 +115,7 @@ func TestChoices(t *testing.T) {
Priority: registry.Default,
Status: func() registry.State { return registry.State{Installed: true, Healthy: true} },
},
choices: []string{"unhealthy", "default", "discouraged"},
choices: []string{"default", "discouraged", "unhealthy"},
pick: "default",
alts: []string{"discouraged"},
},
@@ -125,13 +125,13 @@ func TestChoices(t *testing.T) {
Priority: registry.Preferred,
Status: func() registry.State { return registry.State{Installed: true, Healthy: true} },
},
choices: []string{"preferred", "default", "unhealthy", "discouraged"},
choices: []string{"preferred", "default", "discouraged", "unhealthy"},
pick: "preferred",
alts: []string{"default", "discouraged"},
},
{
requested: "unhealthy",
choices: []string{"preferred", "unhealthy", "default", "discouraged"},
choices: []string{"preferred", "default", "discouraged", "unhealthy"},
pick: "unhealthy",
alts: []string{"preferred", "default", "discouraged"},
},
14 changes: 13 additions & 1 deletion pkg/minikube/registry/global.go
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ package registry

import (
"os"
"sort"

"github.com/golang/glog"
)
@@ -65,8 +66,19 @@ func Available() []DriverState {
}
s := d.Status()
glog.Infof("%s priority: %d, state: %+v", d.Name, d.Priority, s)
sts = append(sts, DriverState{Name: d.Name, Priority: d.Priority, State: s})

priority := d.Priority
if !s.Healthy {
priority = Unhealthy
}

sts = append(sts, DriverState{Name: d.Name, Priority: priority, State: s})
}

// Descending priority for predictability
sort.Slice(sts, func(i, j int) bool {
return sts[i].Priority > sts[j].Priority
})
return sts
}

22 changes: 18 additions & 4 deletions pkg/minikube/registry/global_test.go
Original file line number Diff line number Diff line change
@@ -72,19 +72,33 @@ func TestGlobalAvailable(t *testing.T) {
}

bar := DriverDef{
Name: "bar",
Name: "healthy-bar",
Priority: Default,
Status: func() State { return State{} },
Status: func() State { return State{Healthy: true} },
}
if err := Register(bar); err != nil {
t.Errorf("register returned error: %v", err)
}

foo := DriverDef{
Name: "unhealthy-foo",
Priority: Default,
Status: func() State { return State{Healthy: false} },
}
if err := Register(foo); err != nil {
t.Errorf("register returned error: %v", err)
}

expected := []DriverState{
{
Name: "bar",
Name: "healthy-bar",
Priority: Default,
State: State{},
State: State{Healthy: true},
},
{
Name: "unhealthy-foo",
Priority: Unhealthy,
State: State{Healthy: false},
},
}

16 changes: 8 additions & 8 deletions pkg/minikube/registry/registry.go
Original file line number Diff line number Diff line change
@@ -29,20 +29,20 @@ import (
type Priority int

const (
// Unknown priority
// Unknown is when there is no status check available
Unknown Priority = iota
// Discouraged priority
// Unhealthy is when a driver does not pass health checks
Unhealthy
// Discouraged is when a driver has caveats that preclude it's recommendation
Discouraged
// Deprecated priority
// Deprecated is when a driver has been formally deprecated
Deprecated
// Fallback priority
// Fallback is when a driver works well, but may not be high performance
Fallback
// Default priority
// Default is what what most 3rd party drivers are
Default
// Preferred priority
// Preferred is for drivers that use a native hypervisor interface
Preferred
// StronglyPreferred priority
StronglyPreferred
)

// Registry contains all the supported driver definitions on the host