@@ -17,6 +17,7 @@ limitations under the License.
1717package nas
1818
1919import (
20+ "context"
2021 "errors"
2122 "fmt"
2223 "os"
@@ -27,7 +28,8 @@ import (
2728
2829 "github.com/alibabacloud-go/tea/tea"
2930 "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/losetup"
30- mounter "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter/utils"
31+ "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter"
32+ mounterutils "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter/utils"
3133 "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/nas/cloud"
3234 "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/nas/interfaces"
3335 "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/utils"
@@ -52,6 +54,8 @@ const (
5254 TcpSlotTableEntries = "/proc/sys/sunrpc/tcp_slot_table_entries"
5355 TcpSlotTableEntriesValue = "128\n "
5456
57+ akIDKey = "akId"
58+ akSecretKey = "akSecret"
5559 filesystemIDKey = "fileSystemId"
5660 filesystemTypeKey = "fileSystemType"
5761)
@@ -66,11 +70,12 @@ type RoleAuth struct {
6670 Code string
6771}
6872
69- func doMount (mounter mountutils. Interface , opt * Options , targetPath , volumeId , podUid string ) error {
73+ func doMount (m mounter. Mounter , opt * Options , targetPath , volumeId , podUid string ) error {
7074 var (
7175 mountFstype string
7276 source string
7377 combinedOptions []string
78+ secrets map [string ]string
7479 isPathNotFound func (error ) bool
7580 )
7681 if opt .Accesspoint != "" {
@@ -81,6 +86,12 @@ func doMount(mounter mountutils.Interface, opt *Options, targetPath, volumeId, p
8186 if opt .Options != "" {
8287 combinedOptions = append (combinedOptions , opt .Options )
8388 }
89+ if opt .AkID != "" && opt .AkSecret != "" {
90+ secrets = map [string ]string {
91+ akIDKey : opt .AkID ,
92+ akSecretKey : opt .AkSecret ,
93+ }
94+ }
8495
8596 switch opt .ClientType {
8697 case EFCClient :
@@ -127,7 +138,15 @@ func doMount(mounter mountutils.Interface, opt *Options, targetPath, volumeId, p
127138 return strings .Contains (err .Error (), "reason given by server: No such file or directory" ) || strings .Contains (err .Error (), "access denied by server while mounting" )
128139 }
129140 }
130- err := mounter .Mount (source , targetPath , mountFstype , combinedOptions )
141+
142+ err := m .ExtendedMount (context .Background (), & mounter.MountOperation {
143+ Source : source ,
144+ Target : targetPath ,
145+ FsType : mountFstype ,
146+ Options : combinedOptions ,
147+ Secrets : secrets ,
148+ VolumeID : volumeId ,
149+ })
131150 if err == nil {
132151 return nil
133152 }
@@ -154,16 +173,30 @@ func doMount(mounter mountutils.Interface, opt *Options, targetPath, volumeId, p
154173 return err
155174 }
156175 defer os .Remove (tmpPath )
157- if err := mounter .Mount (rootSource , tmpPath , mountFstype , combinedOptions ); err != nil {
176+ if err := m .ExtendedMount (context .Background (), & mounter.MountOperation {
177+ Source : rootSource ,
178+ Target : tmpPath ,
179+ FsType : mountFstype ,
180+ Options : combinedOptions ,
181+ Secrets : secrets ,
182+ VolumeID : volumeId ,
183+ }); err != nil {
158184 return err
159185 }
160186 if err := os .MkdirAll (filepath .Join (tmpPath , relPath ), os .ModePerm ); err != nil {
161187 return err
162188 }
163- if err := cleanupMountpoint (mounter , tmpPath ); err != nil {
189+ if err := cleanupMountpoint (m , tmpPath ); err != nil {
164190 klog .Errorf ("failed to cleanup tmp mountpoint %s: %v" , tmpPath , err )
165191 }
166- return mounter .Mount (source , targetPath , mountFstype , combinedOptions )
192+ return m .ExtendedMount (context .Background (), & mounter.MountOperation {
193+ Source : source ,
194+ Target : targetPath ,
195+ FsType : mountFstype ,
196+ Options : combinedOptions ,
197+ Secrets : secrets ,
198+ VolumeID : volumeId ,
199+ })
167200}
168201
169202// check system config,
@@ -181,7 +214,7 @@ func ParseMountFlags(mntOptions []string) (string, string) {
181214 var vers string
182215 var otherOptions []string
183216 for _ , options := range mntOptions {
184- for _ , option := range mounter .SplitMountOptions (options ) {
217+ for _ , option := range mounterutils .SplitMountOptions (options ) {
185218 if option == "" {
186219 continue
187220 }
@@ -201,7 +234,7 @@ func ParseMountFlags(mntOptions []string) (string, string) {
201234
202235func addTLSMountOptions (baseOptions []string ) []string {
203236 for _ , options := range baseOptions {
204- for _ , option := range mounter .SplitMountOptions (options ) {
237+ for _ , option := range mounterutils .SplitMountOptions (options ) {
205238 if option == "" {
206239 continue
207240 }
0 commit comments