@@ -165,7 +165,9 @@ func main() {
165165
166166 // Connect to CSI.
167167 metricsManager := metrics .NewCSIMetricsManager ("" /* driverName */ )
168+ ctx := context .Background ()
168169 csiConn , err := connection .Connect (
170+ ctx ,
169171 * csiAddress ,
170172 metricsManager ,
171173 connection .OnConnectionLoss (connection .ExitOnConnectionLoss ()))
@@ -175,11 +177,11 @@ func main() {
175177 }
176178
177179 // Pass a context with a timeout
178- ctx , cancel := context .WithTimeout (context . Background () , * csiTimeout )
180+ tctx , cancel := context .WithTimeout (ctx , * csiTimeout )
179181 defer cancel ()
180182
181183 // Find driver name
182- driverName , err := csirpc .GetDriverName (ctx , csiConn )
184+ driverName , err := csirpc .GetDriverName (tctx , csiConn )
183185 if err != nil {
184186 klog .Errorf ("error getting CSI driver name: %v" , err )
185187 os .Exit (1 )
@@ -202,13 +204,15 @@ func main() {
202204 }
203205
204206 // Check it's ready
205- if err = csirpc .ProbeForever (csiConn , * csiTimeout ); err != nil {
207+ if err = csirpc .ProbeForever (ctx , csiConn , * csiTimeout ); err != nil {
206208 klog .Errorf ("error waiting for CSI driver to be ready: %v" , err )
207209 os .Exit (1 )
208210 }
209211
210212 // 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 )
212216 if err != nil {
213217 klog .Errorf ("error determining if driver supports create/delete snapshot operations: %v" , err )
214218 os .Exit (1 )
@@ -228,7 +232,9 @@ func main() {
228232 snapShotter := snapshotter .NewSnapshotter (csiConn )
229233 var groupSnapshotter group_snapshotter.GroupSnapshotter
230234 if * enableVolumeGroupSnapshots {
231- supportsCreateVolumeGroupSnapshot , err := supportsGroupControllerCreateVolumeGroupSnapshot (ctx , csiConn )
235+ tctx , cancel = context .WithTimeout (ctx , * csiTimeout )
236+ defer cancel ()
237+ supportsCreateVolumeGroupSnapshot , err := supportsGroupControllerCreateVolumeGroupSnapshot (tctx , csiConn )
232238 if err != nil {
233239 klog .Errorf ("error determining if driver supports create/delete group snapshot operations: %v" , err )
234240 } else if ! supportsCreateVolumeGroupSnapshot {
0 commit comments