fix: comments(only create parent dir)

This commit is contained in:
andyzhangx 2020-04-21 07:15:02 +00:00
parent b3a27c44bf
commit 8d5c65b8cd
2 changed files with 9 additions and 17 deletions

View File

@ -276,16 +276,12 @@ func (c *csiAttacher) MountDevice(spec *volume.Spec, devicePath string, deviceMo
// Store volume metadata for UnmountDevice. Keep it around even if the
// driver does not support NodeStage, UnmountDevice still needs it.
if err = os.MkdirAll(deviceMountPath, 0750); err != nil {
if isCorruptedDir(deviceMountPath) {
// leave to CSI driver to handle corrupted mount
klog.Warning(log("attacher.MountDevice detected corrupted mount for dir [%s]", deviceMountPath))
} else {
return errors.New(log("attacher.MountDevice failed to create dir %#v: %v", deviceMountPath, err))
}
parentDir := filepath.Dir(deviceMountPath)
if err = os.MkdirAll(parentDir, 0750); err != nil {
return errors.New(log("attacher.MountDevice failed to create dir %#v: %v", parentDir, err))
}
klog.V(4).Info(log("created target path successfully [%s]", deviceMountPath))
dataDir := filepath.Dir(deviceMountPath)
klog.V(4).Info(log("created target path successfully [%s]", parentDir))
dataDir := parentDir
data := map[string]string{
volDataKey.volHandle: csiSource.VolumeHandle,
volDataKey.driverName: csiSource.Driver,

View File

@ -202,15 +202,11 @@ func (c *csiMountMgr) SetUpAt(dir string, mounterArgs volume.MounterArgs) error
}
// create target_dir before call to NodePublish
if err := os.MkdirAll(dir, 0750); err != nil {
if isCorruptedDir(dir) {
// leave to CSI driver to handle corrupted mount
klog.Warning(log("mounter.SetUpAt detected corrupted mount for dir [%s]", dir))
} else {
return errors.New(log("mounter.SetUpAt failed to create dir %#v: %v", dir, err))
}
parentDir := filepath.Dir(dir)
if err := os.MkdirAll(parentDir, 0750); err != nil {
return errors.New(log("mounter.SetUpAt failed to create dir %#v: %v", parentDir, err))
}
klog.V(4).Info(log("created target path successfully [%s]", dir))
klog.V(4).Info(log("created target path successfully [%s]", parentDir))
nodePublishSecrets = map[string]string{}
if secretRef != nil {