Skip to content

Commit

Permalink
fix: need to check the device path exist first before checking
Browse files Browse the repository at this point in the history
filesystem type and doing formatting

longhorn-10416

Signed-off-by: Phan Le <phan.le@suse.com>
  • Loading branch information
PhanLe1010 authored and derekbit committed Feb 15, 2025
1 parent 5f8a224 commit f56e330
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions csi/node_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ func (ns *NodeServer) nodeStageMountVolume(volumeID, devicePath, stagingTargetPa
return nil
}

if _, err := os.Stat(devicePath); err != nil {
return status.Error(codes.Internal, errors.Wrapf(err, "failed to check if device %v exists", devicePath).Error())
}

log.Infof("Formatting device %v with fsType %v and mounting at %v with mount flags %v", devicePath, fsType, stagingTargetPath, mountFlags)
if err := mounter.FormatAndMount(devicePath, stagingTargetPath, fsType, mountFlags); err != nil {
return status.Error(codes.Internal, err.Error())
Expand Down

0 comments on commit f56e330

Please sign in to comment.