Fix mount options in FibreChannel volumes

Do not mount volumes in WaitForAttach(), mount them in MountDevice()
instead. They will get proper mount options this way.
This commit is contained in:
Jan Safranek
2020-03-17 11:41:00 +01:00
parent f60a0c8660
commit 58129fd12c
4 changed files with 4 additions and 35 deletions

View File

@@ -24,7 +24,7 @@ import (
"strings"
"testing"
"k8s.io/utils/exec/testing"
testingexec "k8s.io/utils/exec/testing"
"k8s.io/utils/mount"
v1 "k8s.io/api/core/v1"
@@ -122,10 +122,6 @@ func (fake *fakeDiskManager) AttachDisk(b fcDiskMounter) (string, error) {
if err != nil {
return "", err
}
// Simulate the global mount so that the fakeMounter returns the
// expected number of mounts for the attached disk.
b.mounter.Mount(globalPath, globalPath, b.fsType, nil)
fake.attachCalled = true
return "", nil
}

View File

@@ -27,7 +27,6 @@ import (
"k8s.io/klog"
"k8s.io/utils/mount"
v1 "k8s.io/api/core/v1"
"k8s.io/kubernetes/pkg/volume"
volumeutil "k8s.io/kubernetes/pkg/volume/util"
)
@@ -242,34 +241,7 @@ func (util *fcUtil) AttachDisk(b fcDiskMounter) (string, error) {
return "", err
}
// If the volumeMode is 'Block', plugin don't have to format the volume.
// The globalPDPath will be created by operationexecutor. Just return devicePath here.
klog.V(5).Infof("fc: AttachDisk volumeMode: %s, devicePath: %s", b.volumeMode, devicePath)
if b.volumeMode == v1.PersistentVolumeBlock {
return devicePath, nil
}
// mount it
globalPDPath := util.MakeGlobalPDName(*b.fcDisk)
if err := os.MkdirAll(globalPDPath, 0750); err != nil {
return devicePath, fmt.Errorf("fc: failed to mkdir %s, error", globalPDPath)
}
noMnt, err := b.mounter.IsLikelyNotMountPoint(globalPDPath)
if err != nil {
return devicePath, fmt.Errorf("Heuristic determination of mount point failed:%v", err)
}
if !noMnt {
klog.Infof("fc: %s already mounted", globalPDPath)
return devicePath, nil
}
err = b.mounter.FormatAndMount(devicePath, globalPDPath, b.fsType, b.mountOptions)
if err != nil {
return devicePath, fmt.Errorf("fc: failed to mount fc volume %s [%s] to %s, error %v", devicePath, b.fsType, globalPDPath, err)
}
return devicePath, err
return devicePath, nil
}
// DetachDisk removes scsi device file such as /dev/sdX from the node.

View File

@@ -20,6 +20,7 @@ go_library(
"//pkg/kubelet/config:go_default_library",
"//pkg/volume:go_default_library",
"//pkg/volume/util:go_default_library",
"//pkg/volume/util/types:go_default_library",
"//pkg/volume/util/volumepathhandler:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",

View File

@@ -466,7 +466,7 @@ func (util *ISCSIUtil) AttachDisk(b iscsiDiskMounter) (string, error) {
// is deleted.
return "", types.NewUncertainProgressError(err.Error())
}
return devicePath, util.persistISCSI(b)
return devicePath, nil
}
// persistISCSI saves iSCSI volume configuration for DetachDisk into global