Keep original preference, for identical priority
Unhealthy drivers have their priority loweredpull/11355/head
parent
dedfdfbfcf
commit
6d0763648e
|
@ -590,7 +590,12 @@ 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:")
|
||||
sort.Slice(rejects, func(i, j int) bool { return rejects[i].Priority > rejects[j].Priority })
|
||||
sort.Slice(rejects, func(i, j int) bool {
|
||||
if rejects[i].Priority == rejects[j].Priority {
|
||||
return rejects[i].Preference > rejects[j].Preference
|
||||
}
|
||||
return rejects[i].Priority > rejects[j].Priority
|
||||
})
|
||||
for _, r := range rejects {
|
||||
if !r.Default {
|
||||
continue
|
||||
|
|
|
@ -66,10 +66,11 @@ var (
|
|||
|
||||
// DriverState is metadata relating to a driver and status
|
||||
type DriverState struct {
|
||||
Name string
|
||||
Default bool
|
||||
Priority Priority
|
||||
State State
|
||||
Name string
|
||||
Default bool
|
||||
Preference Priority
|
||||
Priority Priority
|
||||
State State
|
||||
// Rejection is why we chose not to use this driver
|
||||
Rejection string
|
||||
// Suggestion is how the user could improve health
|
||||
|
@ -112,6 +113,7 @@ func Available(vm bool) []DriverState {
|
|||
s := d.Status()
|
||||
klog.Infof("%s default: %v priority: %d, state: %+v", d.Name, d.Default, d.Priority, s)
|
||||
|
||||
preference := d.Priority
|
||||
priority := d.Priority
|
||||
if !s.Healthy {
|
||||
priority = Unhealthy
|
||||
|
@ -119,10 +121,10 @@ func Available(vm bool) []DriverState {
|
|||
|
||||
if vm {
|
||||
if IsVM(d.Name) {
|
||||
sts = append(sts, DriverState{Name: d.Name, Default: d.Default, Priority: priority, State: s})
|
||||
sts = append(sts, DriverState{Name: d.Name, Default: d.Default, Preference: preference, Priority: priority, State: s})
|
||||
}
|
||||
} else {
|
||||
sts = append(sts, DriverState{Name: d.Name, Default: d.Default, Priority: priority, State: s})
|
||||
sts = append(sts, DriverState{Name: d.Name, Default: d.Default, Preference: preference, Priority: priority, State: s})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,16 +93,18 @@ func TestGlobalAvailable(t *testing.T) {
|
|||
|
||||
expected := []DriverState{
|
||||
{
|
||||
Name: "healthy-bar",
|
||||
Default: true,
|
||||
Priority: Default,
|
||||
State: State{Healthy: true},
|
||||
Name: "healthy-bar",
|
||||
Default: true,
|
||||
Preference: Default,
|
||||
Priority: Default,
|
||||
State: State{Healthy: true},
|
||||
},
|
||||
{
|
||||
Name: "unhealthy-foo",
|
||||
Default: true,
|
||||
Priority: Unhealthy,
|
||||
State: State{Healthy: false},
|
||||
Name: "unhealthy-foo",
|
||||
Default: true,
|
||||
Preference: Default,
|
||||
Priority: Unhealthy,
|
||||
State: State{Healthy: false},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue