Skip to content

Commit c15057c

Browse files
authored
Merge pull request #93 from andrewsykim/timeout-fix
add csi timeout flag
2 parents e52077f + 35d8184 commit c15057c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cmd/csi-snapshotter/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const (
5151
threads = 10
5252

5353
// Default timeout of short CSI calls like GetPluginInfo
54-
csiTimeout = time.Second
54+
defaultCSITimeout = time.Minute
5555
)
5656

5757
// Command line flags
@@ -66,6 +66,7 @@ var (
6666
snapshotNamePrefix = flag.String("snapshot-name-prefix", "snapshot", "Prefix to apply to the name of a created snapshot")
6767
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.")
6868
showVersion = flag.Bool("version", false, "Show version.")
69+
csiTimeout = flag.Duration("timeout", defaultCSITimeout, "The timeout for any RPCs to the CSI driver. Default is 10s.")
6970

7071
leaderElection = flag.Bool("leader-election", false, "Enables leader election.")
7172
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() {
142143
}
143144

144145
// Pass a context with a timeout
145-
ctx, cancel := context.WithTimeout(context.Background(), csiTimeout)
146+
ctx, cancel := context.WithTimeout(context.Background(), *csiTimeout)
146147
defer cancel()
147148

148149
// Find driver name
@@ -155,10 +156,9 @@ func main() {
155156
klog.V(2).Infof("CSI driver name: %q", *snapshotterName)
156157

157158
// Check it's ready
158-
if err = csirpc.ProbeForever(csiConn, csiTimeout); err != nil {
159+
if err = csirpc.ProbeForever(csiConn, *csiTimeout); err != nil {
159160
klog.Errorf("error waiting for CSI driver to be ready: %v", err)
160161
os.Exit(1)
161-
162162
}
163163

164164
// Find out if the driver supports create/delete snapshot.
@@ -191,7 +191,7 @@ func main() {
191191
*createSnapshotContentRetryCount,
192192
*createSnapshotContentInterval,
193193
snapShotter,
194-
*connectionTimeout,
194+
*csiTimeout,
195195
*resyncPeriod,
196196
*snapshotNamePrefix,
197197
*snapshotNameUUIDLength,

0 commit comments

Comments
 (0)