From 3e570ad36d4b1ac0cd96f9190bf5753e6c5bbc70 Mon Sep 17 00:00:00 2001 From: Yecheng Fu Date: Sat, 21 Oct 2017 12:41:18 +0800 Subject: [PATCH] RBD Plugin: Remove deviceMountPath before return on error Attach.MountDevice. --- pkg/volume/rbd/attacher.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/volume/rbd/attacher.go b/pkg/volume/rbd/attacher.go index a7df8dbeb63..f08f499ec7f 100644 --- a/pkg/volume/rbd/attacher.go +++ b/pkg/volume/rbd/attacher.go @@ -153,6 +153,7 @@ func (attacher *rbdAttacher) MountDevice(spec *volume.Spec, devicePath string, d mountOptions := volume.MountOptionFromSpec(spec, options...) err = attacher.plugin.mounter.FormatAndMount(devicePath, deviceMountPath, fstype, mountOptions) if err != nil { + os.Remove(deviceMountPath) return fmt.Errorf("rbd: failed to mount device %s at %s (fstype: %s), error %v", devicePath, deviceMountPath, fstype, err) } glog.V(3).Infof("rbd: successfully mount device %s at %s (fstype: %s)", devicePath, deviceMountPath, fstype)