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

fix: add 20s timeout to driver status check #17553

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 19 additions & 5 deletions pkg/minikube/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"sort"
"strconv"
"strings"
"time"

"golang.org/x/text/cases"
"golang.org/x/text/language"
Expand Down Expand Up @@ -354,12 +355,25 @@ func Suggest(options []registry.DriverState) (registry.DriverState, []registry.D
// Status returns the status of a driver
func Status(name string) registry.DriverState {
d := registry.Driver(name)
return registry.DriverState{
Name: d.Name,
Default: d.Default,
Priority: d.Priority,
State: registry.Status(name),
stateChannel := make(chan registry.State)
timeoutChannel := time.After(20 * time.Second)
go func() {
stateChannel <- registry.Status(name)
}()
select {
case s := <-stateChannel:
return registry.DriverState{
Name: d.Name,
Default: d.Default,
Priority: d.Priority,
State: s,
}
case <-timeoutChannel:
klog.Infof("time out when checking for status of %s driver", name)
return registry.DriverState{}

}

}

// IsAlias checks if an alias belongs to provided driver by name.
Expand Down
13 changes: 12 additions & 1 deletion pkg/minikube/registry/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"os"
"sort"
"time"

"k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/translate"
Expand Down Expand Up @@ -118,7 +119,17 @@ func Available(vm bool) []DriverState {
klog.Errorf("%q does not implement Status", d.Name)
continue
}
s := d.Status()
stateChannel := make(chan State)
timeoutChannel := time.After(20 * time.Second)
go func() {
stateChannel <- d.Status()
}()
s := State{}
select {
case <-timeoutChannel:
klog.Infof("%s status check timeout!", d.Name)
case s = <-stateChannel:
}
klog.Infof("%s default: %v priority: %d, state: %+v", d.Name, d.Default, d.Priority, s)

preference := d.Priority
Expand Down
Loading