Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions pkg/provisioner/longhornv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ func resolveLonghornV2DevPath(device *diskv1.BlockDevice) (string, error) {
device.Status.DeviceStatus.Details.DeviceType)
}
devPath := ""
if device.Status.DeviceStatus.Details.StorageController == string(diskv1.StorageControllerVirtio) ||
device.Status.DeviceStatus.Details.StorageController == string(diskv1.StorageControllerNVMe) {
// In both of these cases, we should (hopefully!) be able to extract BDF from BusPath
if (device.Status.DeviceStatus.Details.StorageController == string(diskv1.StorageControllerVirtio) ||
device.Status.DeviceStatus.Details.StorageController == string(diskv1.StorageControllerNVMe)) &&
device.Spec.Provisioner.Longhorn.DiskDriver != longhornv1.DiskDriverAio {
// In both of these cases, we should (hopefully!) be able to extract BDF from BusPath,
// but this can't be used with the "aio" disk driver (that needs a regular device path)
if strings.HasPrefix(device.Status.DeviceStatus.Details.BusPath, "pci-") {
devPath = strings.Split(device.Status.DeviceStatus.Details.BusPath, "-")[1]
}
Expand All @@ -187,17 +189,22 @@ func resolveLonghornV2DevPath(device *diskv1.BlockDevice) (string, error) {
}).Warn("Unable to extract BDF from BusPath, falling back to WWN")
}
if wwn := device.Status.DeviceStatus.Details.WWN; valueExists(wwn) {
devPath = "/dev/disk/by-id/wwn-" + wwn
if device.Status.DeviceStatus.Details.StorageController == string(diskv1.StorageControllerNVMe) {
devPath = "/dev/disk/by-id/nvme-" + wwn
} else {
devPath = "/dev/disk/by-id/wwn-" + wwn
}
_, err := os.Stat(devPath)
if err == nil {
return devPath, nil
}
logrus.WithFields(logrus.Fields{
"device": device.Name,
"wwn": device.Status.DeviceStatus.Details.WWN,
}).Warn("/dev/disk/by-id/wwn-* path does not exist for device")
}).Warn("/dev/disk/by-id/* path does not exist for device")
}
if busPath := device.Status.DeviceStatus.Details.BusPath; valueExists(busPath) {
// This won't work for LHv2 devices util https://github.com/longhorn/longhorn/issues/13228 is fixed
devPath = "/dev/disk/by-path/" + busPath
_, err := os.Stat(devPath)
if err == nil {
Expand Down
Loading