Fix nil err cause nbd fail to mount

This commit is contained in:
james58899 2019-06-29 14:01:41 +08:00 committed by mergify[bot]
parent 027331c186
commit 1e8fa38879

View File

@ -176,13 +176,14 @@ func getnbdDevicePath(nbdPath, imgPath string, count int) (string, error) {
// rbd-nbd map pool/image ... // rbd-nbd map pool/image ...
if len(cmdlineArgs) < 3 || cmdlineArgs[0] != rbdTonbd || cmdlineArgs[1] != "map" { if len(cmdlineArgs) < 3 || cmdlineArgs[0] != rbdTonbd || cmdlineArgs[1] != "map" {
klog.V(4).Infof("nbd device %s is not used by rbd", nbdPath) klog.V(4).Infof("nbd device %s is not used by rbd", nbdPath)
return "", err return "", fmt.Errorf("nbd device %s is not used by rbd", nbdPath)
} }
if cmdlineArgs[2] != imgPath { if cmdlineArgs[2] != imgPath {
klog.V(4).Infof("rbd-nbd device %s did not match expected image path: %s with path found: %s", klog.V(4).Infof("rbd-nbd device %s did not match expected image path: %s with path found: %s",
nbdPath, imgPath, cmdlineArgs[2]) nbdPath, imgPath, cmdlineArgs[2])
return "", err return "", fmt.Errorf("rbd-nbd device %s did not match expected image path: %s with path found: %s",
nbdPath, imgPath, cmdlineArgs[2])
} }
devicePath := path.Join("/dev", "nbd"+strconv.Itoa(count)) devicePath := path.Join("/dev", "nbd"+strconv.Itoa(count))
if _, err := os.Lstat(devicePath); err != nil { if _, err := os.Lstat(devicePath); err != nil {