@@ -510,6 +510,11 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
510
510
targetPath := req .StagingTargetPath
511
511
// targetPath format: /var/lib/kubelet/plugins/kubernetes.io/csi/pv/pv-disk-1e7001e0-c54a-11e9-8f89-00163e0e78a0/globalmount
512
512
513
+ if err := os .MkdirAll (targetPath , 0755 ); err != nil {
514
+ klog .Errorf ("NodeStageVolume: create volume %s path %s error: %v" , req .VolumeId , targetPath , err )
515
+ return nil , status .Error (codes .Internal , err .Error ())
516
+ }
517
+
513
518
isBlock := req .GetVolumeCapability ().GetBlock () != nil
514
519
if isBlock {
515
520
targetPath = filepath .Join (targetPath , req .VolumeId )
@@ -527,17 +532,6 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
527
532
return & csi.NodeStageVolumeResponse {}, nil
528
533
}
529
534
530
- if isBlock {
531
- if err := ns .mounter .EnsureBlock (targetPath ); err != nil {
532
- klog .Errorf ("NodeStageVolume: create block volume %s path %s error: %v" , req .VolumeId , targetPath , err )
533
- return nil , status .Error (codes .Internal , err .Error ())
534
- }
535
- } else {
536
- if err := os .MkdirAll (targetPath , 0755 ); err != nil {
537
- klog .Errorf ("NodeStageVolume: create volume %s path %s error: %v" , req .VolumeId , targetPath , err )
538
- return nil , status .Error (codes .Internal , err .Error ())
539
- }
540
- }
541
535
device := ""
542
536
isSharedDisk := false
543
537
if value , ok := req .VolumeContext [SharedEnable ]; ok {
@@ -625,6 +619,10 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
625
619
626
620
// Block volume not need to format
627
621
if isBlock {
622
+ if err := ns .mounter .EnsureBlock (targetPath ); err != nil {
623
+ klog .Errorf ("NodeStageVolume: create block volume %s path %s error: %v" , req .VolumeId , targetPath , err )
624
+ return nil , status .Error (codes .Internal , err .Error ())
625
+ }
628
626
notmounted , err := ns .k8smounter .IsLikelyNotMountPoint (targetPath )
629
627
if err != nil {
630
628
return nil , status .Errorf (codes .Internal , "failed to check if %s is not a mount point: %v" , targetPath , err )
0 commit comments