Skip to content

Commit

Permalink
fix local path check
Browse files Browse the repository at this point in the history
  • Loading branch information
fredkan committed Feb 4, 2021
1 parent 6404234 commit 5649fcc
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions pkg/local/nodeutils.go
Expand Up @@ -68,21 +68,16 @@ func (ns *nodeServer) mountLvm(ctx context.Context, req *csi.NodePublishVolumeRe
return status.Error(codes.Internal, err.Error())
}
}
// Check target mounted
isMnt, err := ns.mounter.IsMounted(targetPath)
if err != nil {
if _, err := os.Stat(targetPath); os.IsNotExist(err) {
if err := os.MkdirAll(targetPath, 0750); err != nil {
log.Errorf("NodePublishVolume: volume %s mkdir target path %s with error: %s", volumeID, targetPath, err.Error())
return status.Error(codes.Internal, err.Error())
}
isMnt = false
} else {
log.Errorf("NodePublishVolume: check volume %s mounted with error: %v", volumeID, err)

// Check targetPath
if _, err := os.Stat(targetPath); os.IsNotExist(err) {
if err := os.MkdirAll(targetPath, 0750); err != nil {
log.Errorf("NodePublishVolume: volume %s mkdir target path %s with error: %s", volumeID, targetPath, err.Error())
return status.Error(codes.Internal, err.Error())
}
}

isMnt := utils.IsMounted(targetPath)
if !isMnt {
var options []string
if req.GetReadonly() {
Expand Down

0 comments on commit 5649fcc

Please sign in to comment.