unmap rbd volume if we fail to get devicepath

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2019-07-26 16:23:39 +05:30
parent 5d85f965df
commit d350b13d02

View File

@ -284,6 +284,11 @@ func createPath(volOpt *rbdVolume, cr *util.Credentials) (string, error) {
}
devicePath, found := waitForPath(volOpt.Pool, image, 10, useNBD)
if !found {
output, err := execCommand(cmdName, []string{
"unmap", imagePath, "--id", cr.ID, "-m", volOpt.Monitors, "--keyfile=" + cr.KeyFile})
if err != nil {
klog.Warningf("rbd: unmap error %v, rbd output: %s", err, string(output))
}
return "", fmt.Errorf("could not map image %s, Timeout after 10s", imagePath)
}
return devicePath, nil