Skip to content

Commit 5713c22

Browse files
authored
Merge pull request kubernetes#81631 from tedyu/vol-local-rmdir
Log the error return from dir removal
2 parents 6b47754 + dad86eb commit 5713c22

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/volume/local/local.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,9 @@ func (dm *deviceMounter) mountLocalBlockDevice(spec *volume.Spec, devicePath str
313313
mountOptions := util.MountOptionFromSpec(spec, options...)
314314
err = dm.mounter.FormatAndMount(devicePath, deviceMountPath, fstype, mountOptions)
315315
if err != nil {
316-
os.Remove(deviceMountPath)
316+
if rmErr := os.Remove(deviceMountPath); rmErr != nil {
317+
klog.Warningf("local: failed to remove %s: %v", deviceMountPath, rmErr)
318+
}
317319
return fmt.Errorf("local: failed to mount device %s at %s (fstype: %s), error %v", devicePath, deviceMountPath, fstype, err)
318320
}
319321
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)
531533
return err
532534
}
533535
}
534-
os.Remove(dir)
536+
if rmErr := os.Remove(dir); rmErr != nil {
537+
klog.Warningf("failed to remove %s: %v", dir, rmErr)
538+
}
535539
return err
536540
}
537541
if !m.readOnly {

0 commit comments

Comments
 (0)