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)
|
pick, alts, rejects := driver.Suggest(choices)
|
||||||
if pick.Name == "" {
|
if pick.Name == "" {
|
||||||
out.Step(style.ThumbsDown, "Unable to pick a default driver. Here is what was considered, in preference order:")
|
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 {
|
for _, r := range rejects {
|
||||||
if !r.Default {
|
if !r.Default {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -68,6 +68,7 @@ var (
|
||||||
type DriverState struct {
|
type DriverState struct {
|
||||||
Name string
|
Name string
|
||||||
Default bool
|
Default bool
|
||||||
|
Preference Priority
|
||||||
Priority Priority
|
Priority Priority
|
||||||
State State
|
State State
|
||||||
// Rejection is why we chose not to use this driver
|
// Rejection is why we chose not to use this driver
|
||||||
|
@ -112,6 +113,7 @@ func Available(vm bool) []DriverState {
|
||||||
s := d.Status()
|
s := d.Status()
|
||||||
klog.Infof("%s default: %v priority: %d, state: %+v", d.Name, d.Default, d.Priority, s)
|
klog.Infof("%s default: %v priority: %d, state: %+v", d.Name, d.Default, d.Priority, s)
|
||||||
|
|
||||||
|
preference := d.Priority
|
||||||
priority := d.Priority
|
priority := d.Priority
|
||||||
if !s.Healthy {
|
if !s.Healthy {
|
||||||
priority = Unhealthy
|
priority = Unhealthy
|
||||||
|
@ -119,10 +121,10 @@ func Available(vm bool) []DriverState {
|
||||||
|
|
||||||
if vm {
|
if vm {
|
||||||
if IsVM(d.Name) {
|
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 {
|
} 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})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,12 +95,14 @@ func TestGlobalAvailable(t *testing.T) {
|
||||||
{
|
{
|
||||||
Name: "healthy-bar",
|
Name: "healthy-bar",
|
||||||
Default: true,
|
Default: true,
|
||||||
|
Preference: Default,
|
||||||
Priority: Default,
|
Priority: Default,
|
||||||
State: State{Healthy: true},
|
State: State{Healthy: true},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "unhealthy-foo",
|
Name: "unhealthy-foo",
|
||||||
Default: true,
|
Default: true,
|
||||||
|
Preference: Default,
|
||||||
Priority: Unhealthy,
|
Priority: Unhealthy,
|
||||||
State: State{Healthy: false},
|
State: State{Healthy: false},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue