Skip to content

Commit

Permalink
Merge pull request #2435 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…2429-to-release-1.29

[release-1.29] feat: support NVME disk
  • Loading branch information
andyzhangx authored Jul 27, 2024
2 parents 43cdbde + 93255a6 commit 4e8581b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion pkg/azuredisk/azure_common_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,25 @@ func scsiHostRescan(io azureutils.IOHandler, _ *mount.SafeFormatAndMount) {

func findDiskByLun(lun int, io azureutils.IOHandler, _ *mount.SafeFormatAndMount) (string, error) {
azureDisks := listAzureDiskPath(io)
return findDiskByLunWithConstraint(lun, io, azureDisks)
device, err := findDiskByLunWithConstraint(lun, io, azureDisks)
if err == nil && device != "" {
return device, nil
}

devPaths := []string{
fmt.Sprintf("/dev/disk/azure/scsi1/lun%d", lun),
fmt.Sprintf("/dev/disk/azure/data/by-lun/%d", lun),
}
klog.Warningf("failed to find disk by lun %d, err %v, fall back to search in following device path: %s", lun, err, devPaths)
for _, devPath := range devPaths {
if _, err := os.Stat(devPath); err == nil {
if device, err := io.Readlink(devPath); err == nil {
klog.V(2).Infof("found device path %s linked to %s by lun %d", devPath, device, lun)
return devPath, nil
}
}
}
return "", fmt.Errorf("failed to find disk by lun %d", lun)
}

func formatAndMount(source, target, fstype string, options []string, m *mount.SafeFormatAndMount) error {
Expand Down

0 comments on commit 4e8581b

Please sign in to comment.