@@ -586,24 +586,19 @@ func (rc *reconciler) updateDevicePath(volumesNeedUpdate map[v1.UniqueVolumeName
586
586
}
587
587
588
588
func getDeviceMountPath (volume * reconstructedVolume ) (string , error ) {
589
- volumeAttacher , err := volume .attachablePlugin .NewAttacher ()
590
- if volumeAttacher == nil || err != nil {
591
- return "" , err
592
- }
593
- deviceMountPath , err :=
594
- volumeAttacher .GetDeviceMountPath (volume .volumeSpec )
595
- if err != nil {
596
- return "" , err
597
- }
598
-
599
589
if volume .blockVolumeMapper != nil {
600
- deviceMountPath , err =
601
- volume .blockVolumeMapper .GetGlobalMapPath (volume .volumeSpec )
602
- if err != nil {
590
+ // for block volume, we return its global map path
591
+ return volume .blockVolumeMapper .GetGlobalMapPath (volume .volumeSpec )
592
+ } else if volume .attachablePlugin != nil {
593
+ // for filesystem volume, we return its device mount path if the plugin implements AttachableVolumePlugin
594
+ volumeAttacher , err := volume .attachablePlugin .NewAttacher ()
595
+ if volumeAttacher == nil || err != nil {
603
596
return "" , err
604
597
}
598
+ return volumeAttacher .GetDeviceMountPath (volume .volumeSpec )
599
+ } else {
600
+ return "" , fmt .Errorf ("blockVolumeMapper or attachablePlugin required" )
605
601
}
606
- return deviceMountPath , nil
607
602
}
608
603
609
604
func (rc * reconciler ) updateStates (volumesNeedUpdate map [v1.UniqueVolumeName ]* reconstructedVolume ) error {
@@ -632,7 +627,8 @@ func (rc *reconciler) updateStates(volumesNeedUpdate map[v1.UniqueVolumeName]*re
632
627
continue
633
628
}
634
629
klog .V (4 ).Infof ("Volume: %s (pod UID %s) is marked as mounted and added into the actual state" , volume .volumeName , volume .podName )
635
- if volume .attachablePlugin != nil {
630
+ // If the volume has device to mount, we mark its device as mounted.
631
+ if volume .attachablePlugin != nil || volume .blockVolumeMapper != nil {
636
632
deviceMountPath , err := getDeviceMountPath (volume )
637
633
if err != nil {
638
634
klog .Errorf ("Could not find device mount path for volume %s" , volume .volumeName )
0 commit comments