From 2c7719ac39ee7811f56927d8fed2cbaaa32e72c3 Mon Sep 17 00:00:00 2001 From: Andrew Kim Date: Thu, 14 Feb 2019 12:31:16 -0500 Subject: [PATCH] add csi timeout flag for request timeouts to CSI driver --- cmd/csi-snapshotter/main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/csi-snapshotter/main.go b/cmd/csi-snapshotter/main.go index f551a2139..109fa3630 100644 --- a/cmd/csi-snapshotter/main.go +++ b/cmd/csi-snapshotter/main.go @@ -51,7 +51,7 @@ const ( threads = 10 // Default timeout of short CSI calls like GetPluginInfo - csiTimeout = time.Second + defaultCSITimeout = 10 * time.Second ) // Command line flags @@ -66,6 +66,7 @@ var ( snapshotNamePrefix = flag.String("snapshot-name-prefix", "snapshot", "Prefix to apply to the name of a created snapshot") snapshotNameUUIDLength = flag.Int("snapshot-name-uuid-length", -1, "Length in characters for the generated uuid of a created snapshot. Defaults behavior is to NOT truncate.") showVersion = flag.Bool("version", false, "Show version.") + csiTimeout = flag.Duration("timeout", defaultCSITimeout, "The timeout for any RPCs to the CSI driver") leaderElection = flag.Bool("leader-election", false, "Enables leader election.") leaderElectionNamespace = flag.String("leader-election-namespace", "", "The namespace where the leader election resource exists. Defaults to the pod namespace if not set.") @@ -142,7 +143,7 @@ func main() { } // Pass a context with a timeout - ctx, cancel := context.WithTimeout(context.Background(), csiTimeout) + ctx, cancel := context.WithTimeout(context.Background(), *csiTimeout) defer cancel() // Find driver name @@ -155,10 +156,9 @@ func main() { klog.V(2).Infof("CSI driver name: %q", *snapshotterName) // Check it's ready - if err = csirpc.ProbeForever(csiConn, csiTimeout); err != nil { + if err = csirpc.ProbeForever(csiConn, *csiTimeout); err != nil { klog.Errorf("error waiting for CSI driver to be ready: %v", err) os.Exit(1) - } // Find out if the driver supports create/delete snapshot. @@ -191,7 +191,7 @@ func main() { *createSnapshotContentRetryCount, *createSnapshotContentInterval, snapShotter, - *connectionTimeout, + *csiTimeout, *resyncPeriod, *snapshotNamePrefix, *snapshotNameUUIDLength,