@@ -107,9 +107,9 @@ func (m *csiBlockMapper) GetGlobalMapPath(spec *volume.Spec) (string, error) {
107
107
return dir , nil
108
108
}
109
109
110
- // getStagingPath returns a staging path for a directory (on the node) that should be used on NodeStageVolume/NodeUnstageVolume
110
+ // GetStagingPath returns a staging path for a directory (on the node) that should be used on NodeStageVolume/NodeUnstageVolume
111
111
// Example: plugins/kubernetes.io/csi/volumeDevices/staging/{specName}
112
- func (m * csiBlockMapper ) getStagingPath () string {
112
+ func (m * csiBlockMapper ) GetStagingPath () string {
113
113
return filepath .Join (m .plugin .host .GetVolumeDevicePluginDir (CSIPluginName ), "staging" , m .specName )
114
114
}
115
115
@@ -143,7 +143,7 @@ func (m *csiBlockMapper) stageVolumeForBlock(
143
143
) (string , error ) {
144
144
klog .V (4 ).Infof (log ("blockMapper.stageVolumeForBlock called" ))
145
145
146
- stagingPath := m .getStagingPath ()
146
+ stagingPath := m .GetStagingPath ()
147
147
klog .V (4 ).Infof (log ("blockMapper.stageVolumeForBlock stagingPath set [%s]" , stagingPath ))
148
148
149
149
// Check whether "STAGE_UNSTAGE_VOLUME" is set
@@ -237,7 +237,7 @@ func (m *csiBlockMapper) publishVolumeForBlock(
237
237
ctx ,
238
238
m .volumeID ,
239
239
m .readOnly ,
240
- m .getStagingPath (),
240
+ m .GetStagingPath (),
241
241
publishPath ,
242
242
accessMode ,
243
243
publishVolumeInfo ,
@@ -255,26 +255,26 @@ func (m *csiBlockMapper) publishVolumeForBlock(
255
255
}
256
256
257
257
// SetUpDevice ensures the device is attached returns path where the device is located.
258
- func (m * csiBlockMapper ) SetUpDevice () error {
258
+ func (m * csiBlockMapper ) SetUpDevice () ( string , error ) {
259
259
if ! m .plugin .blockEnabled {
260
- return errors .New ("CSIBlockVolume feature not enabled" )
260
+ return "" , errors .New ("CSIBlockVolume feature not enabled" )
261
261
}
262
262
klog .V (4 ).Infof (log ("blockMapper.SetUpDevice called" ))
263
263
264
264
// Get csiSource from spec
265
265
if m .spec == nil {
266
- return errors .New (log ("blockMapper.SetUpDevice spec is nil" ))
266
+ return "" , errors .New (log ("blockMapper.SetUpDevice spec is nil" ))
267
267
}
268
268
269
269
csiSource , err := getCSISourceFromSpec (m .spec )
270
270
if err != nil {
271
- return errors .New (log ("blockMapper.SetUpDevice failed to get CSI persistent source: %v" , err ))
271
+ return "" , errors .New (log ("blockMapper.SetUpDevice failed to get CSI persistent source: %v" , err ))
272
272
}
273
273
274
274
driverName := csiSource .Driver
275
275
skip , err := m .plugin .skipAttach (driverName )
276
276
if err != nil {
277
- return errors .New (log ("blockMapper.SetupDevice failed to check CSIDriver for %s: %v" , driverName , err ))
277
+ return "" , errors .New (log ("blockMapper.SetupDevice failed to check CSIDriver for %s: %v" , driverName , err ))
278
278
}
279
279
280
280
var attachment * storage.VolumeAttachment
@@ -284,7 +284,7 @@ func (m *csiBlockMapper) SetUpDevice() error {
284
284
attachID := getAttachmentName (csiSource .VolumeHandle , csiSource .Driver , nodeName )
285
285
attachment , err = m .k8s .StorageV1 ().VolumeAttachments ().Get (context .TODO (), attachID , meta.GetOptions {})
286
286
if err != nil {
287
- return errors .New (log ("blockMapper.SetupDevice failed to get volume attachment [id=%v]: %v" , attachID , err ))
287
+ return "" , errors .New (log ("blockMapper.SetupDevice failed to get volume attachment [id=%v]: %v" , attachID , err ))
288
288
}
289
289
}
290
290
@@ -299,11 +299,11 @@ func (m *csiBlockMapper) SetUpDevice() error {
299
299
300
300
csiClient , err := m .csiClientGetter .Get ()
301
301
if err != nil {
302
- return errors .New (log ("blockMapper.SetUpDevice failed to get CSI client: %v" , err ))
302
+ return "" , errors .New (log ("blockMapper.SetUpDevice failed to get CSI client: %v" , err ))
303
303
}
304
304
305
305
// Call NodeStageVolume
306
- _ , err = m .stageVolumeForBlock (ctx , csiClient , accessMode , csiSource , attachment )
306
+ stagingPath , err : = m .stageVolumeForBlock (ctx , csiClient , accessMode , csiSource , attachment )
307
307
if err != nil {
308
308
if volumetypes .IsOperationFinishedError (err ) {
309
309
cleanupErr := m .cleanupOrphanDeviceFiles ()
@@ -312,10 +312,10 @@ func (m *csiBlockMapper) SetUpDevice() error {
312
312
klog .V (4 ).Infof ("Failed to clean up block volume directory %s" , cleanupErr )
313
313
}
314
314
}
315
- return err
315
+ return "" , err
316
316
}
317
317
318
- return nil
318
+ return stagingPath , nil
319
319
}
320
320
321
321
func (m * csiBlockMapper ) MapPodDevice () (string , error ) {
@@ -435,7 +435,7 @@ func (m *csiBlockMapper) TearDownDevice(globalMapPath, devicePath string) error
435
435
}
436
436
437
437
// Call NodeUnstageVolume
438
- stagingPath := m .getStagingPath ()
438
+ stagingPath := m .GetStagingPath ()
439
439
if _ , err := os .Stat (stagingPath ); err != nil {
440
440
if os .IsNotExist (err ) {
441
441
klog .V (4 ).Infof (log ("blockMapper.TearDownDevice stagingPath(%s) has already been deleted, skip calling NodeUnstageVolume" , stagingPath ))
@@ -471,7 +471,7 @@ func (m *csiBlockMapper) cleanupOrphanDeviceFiles() error {
471
471
472
472
// Remove artifacts of NodeStage.
473
473
// stagingPath: xxx/plugins/kubernetes.io/csi/volumeDevices/staging/<volume name>
474
- stagingPath := m .getStagingPath ()
474
+ stagingPath := m .GetStagingPath ()
475
475
if err := os .Remove (stagingPath ); err != nil && ! os .IsNotExist (err ) {
476
476
return errors .New (log ("failed to delete volume staging path [%s]: %v" , stagingPath , err ))
477
477
}
0 commit comments