Skip to content

Commit b4762de

Browse files
tserongVicente-Cheng
authored andcommitted
fix: make LHv2 fall back to by-path for disks without WWNs
Signed-off-by: Tim Serong <tserong@suse.com> (cherry picked from commit c289402)
1 parent bbd673f commit b4762de

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

pkg/provisioner/longhornv2.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,16 @@ func resolveLonghornV2DevPath(device *diskv1.BlockDevice) (string, error) {
197197
"wwn": device.Status.DeviceStatus.Details.WWN,
198198
}).Warn("/dev/disk/by-id/wwn-* path does not exist for device")
199199
}
200-
// TODO: see if we can find something else under /dev/disk/by-id, for
201-
// example maybe there's a serial number but no WWN. In the "no WWN"
202-
// case, maybe it's sufficient to just take whatever path we can find
203-
// under /dev/disk/by-id that links back to the device...?
204-
return "", fmt.Errorf("unable to resolve Longhorn V2 device path; %s has no WWN and no BDF", device.Name)
200+
if busPath := device.Status.DeviceStatus.Details.BusPath; valueExists(busPath) {
201+
devPath = "/dev/disk/by-path/" + busPath
202+
_, err := os.Stat(devPath)
203+
if err == nil {
204+
return devPath, nil
205+
}
206+
logrus.WithFields(logrus.Fields{
207+
"device": device.Name,
208+
"buspath": device.Status.DeviceStatus.Details.BusPath,
209+
}).Warn("/dev/disk/by-path/* path does not exist for device")
210+
}
211+
return "", fmt.Errorf("unable to resolve Longhorn V2 device path; %s has no BDF, no WWN, and no BusPath", device.Name)
205212
}

0 commit comments

Comments
 (0)