@@ -1498,41 +1498,64 @@ func (og *operationGenerator) GenerateExpandInUseVolumeFunc(
1498
1498
var simpleErr , detailedErr error
1499
1499
resizeOptions := volume.NodeResizeOptions {
1500
1500
VolumeSpec : volumeToMount .VolumeSpec ,
1501
+ DevicePath : volumeToMount .DevicePath ,
1502
+ }
1503
+ fsVolume , err := util .CheckVolumeModeFilesystem (volumeToMount .VolumeSpec )
1504
+ if err != nil {
1505
+ return volumeToMount .GenerateError ("NodeExpandvolume.CheckVolumeModeFilesystem failed" , err )
1501
1506
}
1502
1507
1503
- attachableVolumePlugin , _ :=
1504
- og .volumePluginMgr .FindAttachablePluginBySpec (volumeToMount .VolumeSpec )
1508
+ if fsVolume {
1509
+ volumeMounter , newMounterErr := volumePlugin .NewMounter (
1510
+ volumeToMount .VolumeSpec ,
1511
+ volumeToMount .Pod ,
1512
+ volume.VolumeOptions {})
1513
+ if newMounterErr != nil {
1514
+ return volumeToMount .GenerateError ("NodeExpandVolume.NewMounter initialization failed" , newMounterErr )
1515
+ }
1505
1516
1506
- if attachableVolumePlugin != nil {
1507
- volumeAttacher , _ := attachableVolumePlugin .NewAttacher ()
1508
- if volumeAttacher != nil {
1509
- resizeOptions .CSIVolumePhase = volume .CSIVolumeStaged
1510
- resizeOptions .DevicePath = volumeToMount .DevicePath
1511
- dmp , err := volumeAttacher .GetDeviceMountPath (volumeToMount .VolumeSpec )
1517
+ resizeOptions .DeviceMountPath = volumeMounter .GetPath ()
1518
+
1519
+ deviceMountableVolumePlugin , _ := og .volumePluginMgr .FindDeviceMountablePluginBySpec (volumeToMount .VolumeSpec )
1520
+ var volumeDeviceMounter volume.DeviceMounter
1521
+ if deviceMountableVolumePlugin != nil {
1522
+ volumeDeviceMounter , _ = deviceMountableVolumePlugin .NewDeviceMounter ()
1523
+ }
1524
+
1525
+ if volumeDeviceMounter != nil {
1526
+ deviceStagePath , err := volumeDeviceMounter .GetDeviceMountPath (volumeToMount .VolumeSpec )
1512
1527
if err != nil {
1513
1528
return volumeToMount .GenerateError ("NodeExpandVolume.GetDeviceMountPath failed" , err )
1514
1529
}
1515
- resizeOptions .DeviceMountPath = dmp
1516
- resizeOptions .DeviceStagePath = dmp
1517
- resizeDone , simpleErr , detailedErr = og .doOnlineExpansion (volumeToMount , actualStateOfWorld , resizeOptions )
1518
- if simpleErr != nil || detailedErr != nil {
1519
- return simpleErr , detailedErr
1520
- }
1521
- if resizeDone {
1522
- return nil , nil
1523
- }
1530
+ resizeOptions .DeviceStagePath = deviceStagePath
1531
+ }
1532
+ } else {
1533
+ // Get block volume mapper plugin
1534
+ blockVolumePlugin , err :=
1535
+ og .volumePluginMgr .FindMapperPluginBySpec (volumeToMount .VolumeSpec )
1536
+ if err != nil {
1537
+ return volumeToMount .GenerateError ("MapVolume.FindMapperPluginBySpec failed" , err )
1538
+ }
1539
+
1540
+ if blockVolumePlugin == nil {
1541
+ return volumeToMount .GenerateError ("MapVolume.FindMapperPluginBySpec failed to find BlockVolumeMapper plugin. Volume plugin is nil." , nil )
1542
+ }
1543
+
1544
+ blockVolumeMapper , newMapperErr := blockVolumePlugin .NewBlockVolumeMapper (
1545
+ volumeToMount .VolumeSpec ,
1546
+ volumeToMount .Pod ,
1547
+ volume.VolumeOptions {})
1548
+ if newMapperErr != nil {
1549
+ return volumeToMount .GenerateError ("MapVolume.NewBlockVolumeMapper initialization failed" , newMapperErr )
1550
+ }
1551
+
1552
+ // if plugin supports custom mappers lets add DeviceStagePath
1553
+ if customBlockVolumeMapper , ok := blockVolumeMapper .(volume.CustomBlockVolumeMapper ); ok {
1554
+ resizeOptions .DeviceStagePath = customBlockVolumeMapper .GetStagingPath ()
1524
1555
}
1525
- }
1526
- // if we are here that means volume plugin does not support attach interface
1527
- volumeMounter , newMounterErr := volumePlugin .NewMounter (
1528
- volumeToMount .VolumeSpec ,
1529
- volumeToMount .Pod ,
1530
- volume.VolumeOptions {})
1531
- if newMounterErr != nil {
1532
- return volumeToMount .GenerateError ("NodeExpandVolume.NewMounter initialization failed" , newMounterErr )
1533
1556
}
1534
1557
1535
- resizeOptions . DeviceMountPath = volumeMounter . GetPath ()
1558
+ // if we are doing online expansion then volume is already published
1536
1559
resizeOptions .CSIVolumePhase = volume .CSIVolumePublished
1537
1560
resizeDone , simpleErr , detailedErr = og .doOnlineExpansion (volumeToMount , actualStateOfWorld , resizeOptions )
1538
1561
if simpleErr != nil || detailedErr != nil {
0 commit comments