Merge pull request #81631 from tedyu/vol-local-rmdir

Log the error return from dir removal
This commit is contained in:
Kubernetes Prow Robot 2019-08-22 11:13:28 -07:00 committed by GitHub
commit 5713c22eec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -313,7 +313,9 @@ func (dm *deviceMounter) mountLocalBlockDevice(spec *volume.Spec, devicePath str
mountOptions := util.MountOptionFromSpec(spec, options...) mountOptions := util.MountOptionFromSpec(spec, options...)
err = dm.mounter.FormatAndMount(devicePath, deviceMountPath, fstype, mountOptions) err = dm.mounter.FormatAndMount(devicePath, deviceMountPath, fstype, mountOptions)
if err != nil { if err != nil {
os.Remove(deviceMountPath) if rmErr := os.Remove(deviceMountPath); rmErr != nil {
klog.Warningf("local: failed to remove %s: %v", deviceMountPath, rmErr)
}
return fmt.Errorf("local: failed to mount device %s at %s (fstype: %s), error %v", devicePath, deviceMountPath, fstype, err) return fmt.Errorf("local: failed to mount device %s at %s (fstype: %s), error %v", devicePath, deviceMountPath, fstype, err)
} }
klog.V(3).Infof("local: successfully mount device %s at %s (fstype: %s)", devicePath, deviceMountPath, fstype) klog.V(3).Infof("local: successfully mount device %s at %s (fstype: %s)", devicePath, deviceMountPath, fstype)
@ -531,7 +533,9 @@ func (m *localVolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs)
return err return err
} }
} }
os.Remove(dir) if rmErr := os.Remove(dir); rmErr != nil {
klog.Warningf("failed to remove %s: %v", dir, rmErr)
}
return err return err
} }
if !m.readOnly { if !m.readOnly {