@@ -165,7 +165,9 @@ func main() {
165
165
166
166
// Connect to CSI.
167
167
metricsManager := metrics .NewCSIMetricsManager ("" /* driverName */ )
168
+ ctx := context .Background ()
168
169
csiConn , err := connection .Connect (
170
+ ctx ,
169
171
* csiAddress ,
170
172
metricsManager ,
171
173
connection .OnConnectionLoss (connection .ExitOnConnectionLoss ()))
@@ -175,11 +177,11 @@ func main() {
175
177
}
176
178
177
179
// Pass a context with a timeout
178
- ctx , cancel := context .WithTimeout (context . Background () , * csiTimeout )
180
+ tctx , cancel := context .WithTimeout (ctx , * csiTimeout )
179
181
defer cancel ()
180
182
181
183
// Find driver name
182
- driverName , err := csirpc .GetDriverName (ctx , csiConn )
184
+ driverName , err := csirpc .GetDriverName (tctx , csiConn )
183
185
if err != nil {
184
186
klog .Errorf ("error getting CSI driver name: %v" , err )
185
187
os .Exit (1 )
@@ -202,13 +204,15 @@ func main() {
202
204
}
203
205
204
206
// Check it's ready
205
- if err = csirpc .ProbeForever (csiConn , * csiTimeout ); err != nil {
207
+ if err = csirpc .ProbeForever (ctx , csiConn , * csiTimeout ); err != nil {
206
208
klog .Errorf ("error waiting for CSI driver to be ready: %v" , err )
207
209
os .Exit (1 )
208
210
}
209
211
210
212
// Find out if the driver supports create/delete snapshot.
211
- supportsCreateSnapshot , err := supportsControllerCreateSnapshot (ctx , csiConn )
213
+ tctx , cancel = context .WithTimeout (ctx , * csiTimeout )
214
+ defer cancel ()
215
+ supportsCreateSnapshot , err := supportsControllerCreateSnapshot (tctx , csiConn )
212
216
if err != nil {
213
217
klog .Errorf ("error determining if driver supports create/delete snapshot operations: %v" , err )
214
218
os .Exit (1 )
@@ -228,7 +232,9 @@ func main() {
228
232
snapShotter := snapshotter .NewSnapshotter (csiConn )
229
233
var groupSnapshotter group_snapshotter.GroupSnapshotter
230
234
if * enableVolumeGroupSnapshots {
231
- supportsCreateVolumeGroupSnapshot , err := supportsGroupControllerCreateVolumeGroupSnapshot (ctx , csiConn )
235
+ tctx , cancel = context .WithTimeout (ctx , * csiTimeout )
236
+ defer cancel ()
237
+ supportsCreateVolumeGroupSnapshot , err := supportsGroupControllerCreateVolumeGroupSnapshot (tctx , csiConn )
232
238
if err != nil {
233
239
klog .Errorf ("error determining if driver supports create/delete group snapshot operations: %v" , err )
234
240
} else if ! supportsCreateVolumeGroupSnapshot {
0 commit comments