@@ -519,6 +519,11 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
519
519
targetPath := req .StagingTargetPath
520
520
// targetPath format: /var/lib/kubelet/plugins/kubernetes.io/csi/pv/pv-disk-1e7001e0-c54a-11e9-8f89-00163e0e78a0/globalmount
521
521
522
+ if err := os .MkdirAll (targetPath , 0755 ); err != nil {
523
+ klog .Errorf ("NodeStageVolume: create volume %s path %s error: %v" , req .VolumeId , targetPath , err )
524
+ return nil , status .Error (codes .Internal , err .Error ())
525
+ }
526
+
522
527
isBlock := req .GetVolumeCapability ().GetBlock () != nil
523
528
if isBlock {
524
529
targetPath = filepath .Join (targetPath , req .VolumeId )
@@ -536,17 +541,6 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
536
541
return & csi.NodeStageVolumeResponse {}, nil
537
542
}
538
543
539
- if isBlock {
540
- if err := ns .mounter .EnsureBlock (targetPath ); err != nil {
541
- klog .Errorf ("NodeStageVolume: create block volume %s path %s error: %v" , req .VolumeId , targetPath , err )
542
- return nil , status .Error (codes .Internal , err .Error ())
543
- }
544
- } else {
545
- if err := os .MkdirAll (targetPath , 0755 ); err != nil {
546
- klog .Errorf ("NodeStageVolume: create volume %s path %s error: %v" , req .VolumeId , targetPath , err )
547
- return nil , status .Error (codes .Internal , err .Error ())
548
- }
549
- }
550
544
device := ""
551
545
isSharedDisk := false
552
546
if value , ok := req .VolumeContext [SharedEnable ]; ok {
@@ -637,6 +631,10 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
637
631
638
632
// Block volume not need to format
639
633
if isBlock {
634
+ if err := ns .mounter .EnsureBlock (targetPath ); err != nil {
635
+ klog .Errorf ("NodeStageVolume: create block volume %s path %s error: %v" , req .VolumeId , targetPath , err )
636
+ return nil , status .Error (codes .Internal , err .Error ())
637
+ }
640
638
notmounted , err := ns .k8smounter .IsLikelyNotMountPoint (targetPath )
641
639
if err != nil {
642
640
return nil , status .Errorf (codes .Internal , "failed to check if %s is not a mount point: %v" , targetPath , err )
0 commit comments