From 9a765f8c2d97a5180737a4a39e217b49180b67d6 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Fri, 6 Nov 2020 15:47:25 +0100 Subject: [PATCH] Restore staging path creation CSI says about NodeStage (=MountDevice): // The CO SHALL ensure [...] // that the path is directory and that the process serving the // request has `read` and `write` permission to that directory. The // CO SHALL be responsible for creating the directory if it does not // exist. --- pkg/volume/csi/csi_attacher.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/volume/csi/csi_attacher.go b/pkg/volume/csi/csi_attacher.go index fe17e4b7ed6..acfff89388f 100644 --- a/pkg/volume/csi/csi_attacher.go +++ b/pkg/volume/csi/csi_attacher.go @@ -276,12 +276,11 @@ 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. - 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)) + if err = os.MkdirAll(deviceMountPath, 0750); err != nil { + return errors.New(log("attacher.MountDevice failed to create dir %#v: %v", deviceMountPath, err)) } - klog.V(4).Info(log("created target path successfully [%s]", parentDir)) - dataDir := parentDir + klog.V(4).Info(log("created target path successfully [%s]", deviceMountPath)) + dataDir := filepath.Dir(deviceMountPath) data := map[string]string{ volDataKey.volHandle: csiSource.VolumeHandle, volDataKey.driverName: csiSource.Driver,