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 <[email protected]>
(cherry picked from commit cb53a16)
  • Loading branch information
PhanLe1010 authored and derekbit committed Feb 15, 2025
1 parent 95a2bbf commit 0f0c9ba
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 0f0c9ba

Please sign in to comment.