From dad86eb4cbf6d09f0bbada8dc021a672e8973362 Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Mon, 19 Aug 2019 20:51:22 -0700 Subject: [PATCH] Log the error return from dir removal --- pkg/volume/local/local.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/volume/local/local.go b/pkg/volume/local/local.go index 88ce005eeac..be043a1a503 100644 --- a/pkg/volume/local/local.go +++ b/pkg/volume/local/local.go @@ -313,7 +313,9 @@ func (dm *deviceMounter) mountLocalBlockDevice(spec *volume.Spec, devicePath str mountOptions := util.MountOptionFromSpec(spec, options...) err = dm.mounter.FormatAndMount(devicePath, deviceMountPath, fstype, mountOptions) 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) } 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 } } - os.Remove(dir) + if rmErr := os.Remove(dir); rmErr != nil { + klog.Warningf("failed to remove %s: %v", dir, rmErr) + } return err } if !m.readOnly {