@@ -66,7 +66,7 @@ type RoleAuth struct {
6666 Code string
6767}
6868
69- func doMount (mounter mountutils.Interface , opt * Options , targetPath , volumeId , podUid string ) error {
69+ func doMount (mounter mountutils.Interface , opt * Options , targetPath , volumeId , podUid string , agentMode bool ) error {
7070 var (
7171 mountFstype string
7272 source string
@@ -94,9 +94,7 @@ func doMount(mounter mountutils.Interface, opt *Options, targetPath, volumeId, p
9494 }
9595 mountFstype = "alinas"
9696 // err = mounter.Mount(source, mountPoint, "alinas", combinedOptions)
97- isPathNotFound = func (err error ) bool {
98- return strings .Contains (err .Error (), "Failed to bind mount" )
99- }
97+ isPathNotFound = isEFCPathNotFoundError
10098 case NativeClient :
10199 switch opt .FSType {
102100 case "cpfs" :
@@ -115,17 +113,20 @@ func doMount(mounter mountutils.Interface, opt *Options, targetPath, volumeId, p
115113 // must enable tls when using accesspoint
116114 combinedOptions = addTLSMountOptions (combinedOptions )
117115 }
116+ isPathNotFound = isNFSPathNotFoundError
118117 // Enable compatibility for BMCPFS VPC mount points using the NAS Driver, to support the same usage in ECI.
119118 if isCPFS (opt .FSType , opt .Server ) && opt .MountProtocol == "efc" {
120119 mountFstype = "alinas"
121120 combinedOptions = append (combinedOptions , "efc,protocol=efc,net=tcp,fstype=cpfs" )
121+ if agentMode {
122+ isPathNotFound = isEFCPathNotFoundError
123+ } else {
124+ klog .V (4 ).InfoS ("CSI will only auto create directory under agent mode when using EFC mount protocol." )
125+ }
122126 }
123127 if mountFstype == "" {
124128 mountFstype = opt .MountProtocol
125129 }
126- isPathNotFound = func (err error ) bool {
127- return strings .Contains (err .Error (), "reason given by server: No such file or directory" ) || strings .Contains (err .Error (), "access denied by server while mounting" )
128- }
129130 }
130131 err := mounter .Mount (source , targetPath , mountFstype , combinedOptions )
131132 if err == nil {
@@ -166,6 +167,23 @@ func doMount(mounter mountutils.Interface, opt *Options, targetPath, volumeId, p
166167 return mounter .Mount (source , targetPath , mountFstype , combinedOptions )
167168}
168169
170+ func isEFCPathNotFoundError (err error ) bool {
171+ return strings .Contains (err .Error (), "Failed to bind mount" )
172+ }
173+
174+ func isNFSPathNotFoundError (err error ) bool {
175+ errors := []string {
176+ "reason given by server: No such file or directory" ,
177+ "access denied by server while mounting" ,
178+ }
179+ for _ , error := range errors {
180+ if strings .Contains (err .Error (), error ) {
181+ return true
182+ }
183+ }
184+ return false
185+ }
186+
169187// check system config,
170188// if tcp_slot_table_entries not set to 128, just config.
171189func checkSystemNasConfig () error {
0 commit comments