Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/nas/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
}

//mount nas client
if err := doMount(ns.mounter, opt, mountPath, req.VolumeId, podUID); err != nil {
if err := doMount(ns.mounter, opt, mountPath, req.VolumeId, podUID, ns.config.AgentMode); err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
if opt.MountProtocol == "efc" {
Expand Down Expand Up @@ -575,7 +575,7 @@ func (ns *nodeServer) mountLosetupPv(mountPoint string, opt *Options, volumeID s
return fmt.Errorf("mountLosetupPv: create nfs mountPath error %s ", err.Error())
}
//mount nas to use losetup dev
err := doMount(ns.mounter, opt, nfsPath, volumeID, podID)
err := doMount(ns.mounter, opt, nfsPath, volumeID, podID, ns.config.AgentMode)
if err != nil {
return fmt.Errorf("mountLosetupPv: mount losetup volume failed: %s", err.Error())
}
Expand Down
32 changes: 25 additions & 7 deletions pkg/nas/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type RoleAuth struct {
Code string
}

func doMount(mounter mountutils.Interface, opt *Options, targetPath, volumeId, podUid string) error {
func doMount(mounter mountutils.Interface, opt *Options, targetPath, volumeId, podUid string, agentMode bool) error {
var (
mountFstype string
source string
Expand Down Expand Up @@ -94,9 +94,7 @@ func doMount(mounter mountutils.Interface, opt *Options, targetPath, volumeId, p
}
mountFstype = "alinas"
// err = mounter.Mount(source, mountPoint, "alinas", combinedOptions)
isPathNotFound = func(err error) bool {
return strings.Contains(err.Error(), "Failed to bind mount")
}
isPathNotFound = isEFCPathNotFoundError
case NativeClient:
switch opt.FSType {
case "cpfs":
Expand All @@ -115,17 +113,20 @@ func doMount(mounter mountutils.Interface, opt *Options, targetPath, volumeId, p
// must enable tls when using accesspoint
combinedOptions = addTLSMountOptions(combinedOptions)
}
isPathNotFound = isNFSPathNotFoundError
// Enable compatibility for BMCPFS VPC mount points using the NAS Driver, to support the same usage in ECI.
if isCPFS(opt.FSType, opt.Server) && opt.MountProtocol == "efc" {
mountFstype = "alinas"
combinedOptions = append(combinedOptions, "efc,protocol=efc,net=tcp,fstype=cpfs")
if agentMode {
isPathNotFound = isEFCPathNotFoundError
} else {
klog.V(4).InfoS("CSI will only auto create directory under agent mode when using EFC mount protocol.")
}
}
if mountFstype == "" {
mountFstype = opt.MountProtocol
}
isPathNotFound = func(err error) bool {
return strings.Contains(err.Error(), "reason given by server: No such file or directory") || strings.Contains(err.Error(), "access denied by server while mounting")
}
}
err := mounter.Mount(source, targetPath, mountFstype, combinedOptions)
if err == nil {
Expand Down Expand Up @@ -166,6 +167,23 @@ func doMount(mounter mountutils.Interface, opt *Options, targetPath, volumeId, p
return mounter.Mount(source, targetPath, mountFstype, combinedOptions)
}

func isEFCPathNotFoundError(err error) bool {
return strings.Contains(err.Error(), "Failed to bind mount")
}

func isNFSPathNotFoundError(err error) bool {
errors := []string{
"reason given by server: No such file or directory",
"access denied by server while mounting",
}
for _, error := range errors {
if strings.Contains(err.Error(), error) {
return true
}
}
return false
}

// check system config,
// if tcp_slot_table_entries not set to 128, just config.
func checkSystemNasConfig() error {
Expand Down