mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
do not remove volume dir when saveVolumeData fails
This commit is contained in:
parent
22dabe6fea
commit
b9afd2d34a
@ -297,11 +297,9 @@ func (c *csiAttacher) MountDevice(spec *volume.Spec, devicePath string, deviceMo
|
||||
volDataKey.driverName: csiSource.Driver,
|
||||
}
|
||||
if err = saveVolumeData(dataDir, volDataFileName, data); err != nil {
|
||||
klog.Error(log("failed to save volume info data: %v", err))
|
||||
if cleanErr := os.RemoveAll(dataDir); cleanErr != nil {
|
||||
klog.Error(log("failed to remove dir after error [%s]: %v", dataDir, cleanErr))
|
||||
}
|
||||
return err
|
||||
errMsg := log("failed to save volume info data: %v", err)
|
||||
klog.Error(errMsg)
|
||||
return errors.New(errMsg)
|
||||
}
|
||||
defer func() {
|
||||
// Only if there was an error and volume operation was considered
|
||||
|
@ -457,10 +457,15 @@ func (p *csiPlugin) NewMounter(
|
||||
volData[volDataKey.attachmentID] = attachID
|
||||
|
||||
if err := saveVolumeData(dataDir, volDataFileName, volData); err != nil {
|
||||
if removeErr := os.RemoveAll(dataDir); removeErr != nil {
|
||||
klog.Error(log("failed to remove dir after error [%s]: %v", dataDir, removeErr))
|
||||
errorMsg := log("csi.NewMounter failed to save volume info data: %v", err)
|
||||
klog.Error(errorMsg)
|
||||
|
||||
// attempt to cleanup volume mount dir.
|
||||
if removeMountDirErr := removeMountDir(p, dir); removeMountDirErr != nil {
|
||||
klog.Error(log("csi.NewMounter failed to remove mount dir [%s]: %v", dir, removeMountDirErr))
|
||||
}
|
||||
return nil, errors.New(log("failed to save volume info data: %v", err))
|
||||
|
||||
return nil, errors.New(errorMsg)
|
||||
}
|
||||
|
||||
klog.V(4).Info(log("mounter created successfully"))
|
||||
|
Loading…
Reference in New Issue
Block a user