Merge pull request #506 from Madhu-1/unmap

unmap rbd volume if we fail to get devicepath
This commit is contained in:
Humble Devassy Chirammal 2019-07-29 13:56:17 +05:30 committed by GitHub
commit fde2a666ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -284,6 +284,11 @@ func createPath(volOpt *rbdVolume, cr *util.Credentials) (string, error) {
} }
devicePath, found := waitForPath(volOpt.Pool, image, 10, useNBD) devicePath, found := waitForPath(volOpt.Pool, image, 10, useNBD)
if !found { 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 "", fmt.Errorf("could not map image %s, Timeout after 10s", imagePath)
} }
return devicePath, nil return devicePath, nil