Skip to content

Commit

Permalink
Fixbug: check driver timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Wiley Wang committed Aug 24, 2018
1 parent 5a4cc3b commit 5956470
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cmd/csi-attacher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ func main() {
os.Exit(1)
}

supportsService, err := csiConn.SupportsPluginControllerService(ctx)
ctxController, cancelController := context.WithTimeout(context.Background(), csiTimeout)
defer cancelController()
supportsService, err := csiConn.SupportsPluginControllerService(ctxController)
if err != nil {
glog.Error(err.Error())
os.Exit(1)
Expand All @@ -130,7 +132,9 @@ func main() {
glog.V(2).Infof("CSI driver does not support Plugin Controller Service, using trivial handler")
} else {
// Find out if the driver supports attach/detach.
supportsAttach, err := csiConn.SupportsControllerPublish(ctx)
ctxPublish, cancelPublish := context.WithTimeout(context.Background(), csiTimeout)
defer cancelPublish()
supportsAttach, err := csiConn.SupportsControllerPublish(ctxPublish)
if err != nil {
glog.Error(err.Error())
os.Exit(1)
Expand Down Expand Up @@ -195,7 +199,7 @@ func waitForDriverReady(csiConn connection.CSIConnection, timeout time.Duration)
finish := now.Add(timeout)
var err error
for {
ctx, cancel := context.WithTimeout(context.Background(), csiTimeout)
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
err = csiConn.Probe(ctx)
if err == nil {
Expand Down

0 comments on commit 5956470

Please sign in to comment.