@@ -37,8 +37,8 @@ import (
37
37
)
38
38
39
39
type csiBlockMapper struct {
40
+ csiClientGetter
40
41
k8s kubernetes.Interface
41
- csiClient csiClient
42
42
plugin * csiPlugin
43
43
driverName csiDriverName
44
44
specName string
@@ -247,14 +247,20 @@ func (m *csiBlockMapper) SetUpDevice() (string, error) {
247
247
ctx , cancel := context .WithTimeout (context .Background (), csiTimeout )
248
248
defer cancel ()
249
249
250
+ csiClient , err := m .csiClientGetter .Get ()
251
+ if err != nil {
252
+ klog .Error (log ("blockMapper.SetUpDevice failed to get CSI client: %v" , err ))
253
+ return "" , err
254
+ }
255
+
250
256
// Call NodeStageVolume
251
- stagingPath , err := m .stageVolumeForBlock (ctx , m . csiClient , accessMode , csiSource , attachment )
257
+ stagingPath , err := m .stageVolumeForBlock (ctx , csiClient , accessMode , csiSource , attachment )
252
258
if err != nil {
253
259
return "" , err
254
260
}
255
261
256
262
// Call NodePublishVolume
257
- publishPath , err := m .publishVolumeForBlock (ctx , m . csiClient , accessMode , csiSource , attachment , stagingPath )
263
+ publishPath , err := m .publishVolumeForBlock (ctx , csiClient , accessMode , csiSource , attachment , stagingPath )
258
264
if err != nil {
259
265
return "" , err
260
266
}
@@ -326,6 +332,12 @@ func (m *csiBlockMapper) TearDownDevice(globalMapPath, devicePath string) error
326
332
ctx , cancel := context .WithTimeout (context .Background (), csiTimeout )
327
333
defer cancel ()
328
334
335
+ csiClient , err := m .csiClientGetter .Get ()
336
+ if err != nil {
337
+ klog .Error (log ("blockMapper.TearDownDevice failed to get CSI client: %v" , err ))
338
+ return err
339
+ }
340
+
329
341
// Call NodeUnpublishVolume
330
342
publishPath := m .getPublishPath ()
331
343
if _ , err := os .Stat (publishPath ); err != nil {
@@ -335,7 +347,7 @@ func (m *csiBlockMapper) TearDownDevice(globalMapPath, devicePath string) error
335
347
return err
336
348
}
337
349
} else {
338
- err := m .unpublishVolumeForBlock (ctx , m . csiClient , publishPath )
350
+ err := m .unpublishVolumeForBlock (ctx , csiClient , publishPath )
339
351
if err != nil {
340
352
return err
341
353
}
@@ -350,7 +362,7 @@ func (m *csiBlockMapper) TearDownDevice(globalMapPath, devicePath string) error
350
362
return err
351
363
}
352
364
} else {
353
- err := m .unstageVolumeForBlock (ctx , m . csiClient , stagingPath )
365
+ err := m .unstageVolumeForBlock (ctx , csiClient , stagingPath )
354
366
if err != nil {
355
367
return err
356
368
}
0 commit comments