From 51e81d2585b65d35106684dfddebe41b0764ede9 Mon Sep 17 00:00:00 2001 From: linyouchong Date: Thu, 19 Jul 2018 10:47:57 +0800 Subject: [PATCH] csiAttacher: check deviceMountPath before hasStageUnstageCapability --- pkg/volume/csi/csi_attacher.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/volume/csi/csi_attacher.go b/pkg/volume/csi/csi_attacher.go index 1709bbac0f8..f5d16019252 100644 --- a/pkg/volume/csi/csi_attacher.go +++ b/pkg/volume/csi/csi_attacher.go @@ -248,6 +248,11 @@ func (c *csiAttacher) GetDeviceMountPath(spec *volume.Spec) (string, error) { func (c *csiAttacher) MountDevice(spec *volume.Spec, devicePath string, deviceMountPath string) (err error) { glog.V(4).Infof(log("attacher.MountDevice(%s, %s)", devicePath, deviceMountPath)) + if deviceMountPath == "" { + err = fmt.Errorf("attacher.MountDevice failed, deviceMountPath is empty") + return err + } + mounted, err := isDirMounted(c.plugin, deviceMountPath) if err != nil { glog.Error(log("attacher.MountDevice failed while checking mount status for dir [%s]", deviceMountPath)) @@ -317,11 +322,6 @@ func (c *csiAttacher) MountDevice(spec *volume.Spec, devicePath string, deviceMo } // Start MountDevice - if deviceMountPath == "" { - err = fmt.Errorf("attacher.MountDevice failed, deviceMountPath is empty") - return err - } - nodeName := string(c.plugin.host.GetNodeName()) attachID := getAttachmentName(csiSource.VolumeHandle, csiSource.Driver, nodeName)