@@ -11,9 +11,11 @@ import (
1111 "syscall"
1212 "time"
1313
14+ "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter"
15+ "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter/interceptors"
1416 "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter/proxy"
1517 "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter/proxy/server"
16- mounter "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter/utils"
18+ mounterutils "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter/utils"
1719 "k8s.io/apimachinery/pkg/util/wait"
1820 "k8s.io/klog/v2"
1921 "k8s.io/mount-utils"
@@ -25,11 +27,16 @@ const (
2527)
2628
2729func init () {
28- server .RegisterDriver (& Driver {mounter : mount .New ("" )})
30+ server .RegisterDriver (& Driver {
31+ Mounter : mounter .NewForMounter (
32+ & extendedMounter {Interface : mount .New ("" )},
33+ interceptors .NewAlinasSecretInterceptor (),
34+ ),
35+ })
2936}
3037
3138type Driver struct {
32- mounter mount. Interface
39+ mounter. Mounter
3340}
3441
3542func (h * Driver ) Name () string {
@@ -41,15 +48,15 @@ func (h *Driver) Fstypes() []string {
4148}
4249
4350func (h * Driver ) Mount (ctx context.Context , req * proxy.MountRequest ) error {
44- klog . InfoS ( "Mounting" , "fstype" , req . Fstype , "source" , req . Source , "target" , req . Target , "options" , req . Options )
45- options := append ( req .Options , "no_start_watchdog" )
46- if req . Fstype == fstypeAlinas {
47- // options = append(options, "no_atomic_move", "auto_fallback_nfs")
48- options = append ( options , "no_atomic_move" )
49- options = addAutoFallbackNFSMountOptions ( options )
50- }
51-
52- return h . mounter . Mount ( req . Source , req . Target , req . Fstype , options )
51+ return h . ExtendedMount ( ctx , & mounter. MountOperation {
52+ Source : req .Source ,
53+ Target : req . Target ,
54+ FsType : req . Fstype ,
55+ Options : req . Options ,
56+ Secrets : req . Secrets ,
57+ MetricsPath : req . MetricsPath ,
58+ VolumeID : req . VolumeID ,
59+ } )
5360}
5461
5562func (h * Driver ) Init () {
@@ -79,7 +86,7 @@ func addAutoFallbackNFSMountOptions(mountOptions []string) []string {
7986 isEFC := false
8087 isVSC := false
8188 for _ , options := range mountOptions {
82- for _ , option := range mounter .SplitMountOptions (options ) {
89+ for _ , option := range mounterutils .SplitMountOptions (options ) {
8390 if option == "" {
8491 continue
8592 }
@@ -158,3 +165,20 @@ func copyFile(src, dst string) error {
158165
159166 return dstFile .Sync ()
160167}
168+
169+ type extendedMounter struct {
170+ mount.Interface
171+ }
172+
173+ var _ mounter.Mounter = & extendedMounter {}
174+
175+ func (m * extendedMounter ) ExtendedMount (ctx context.Context , op * mounter.MountOperation ) error {
176+ klog .InfoS ("Mounting" , "fstype" , op .FsType , "source" , op .Source , "target" , op .Target , "options" , op .Options )
177+ op .Options = append (op .Options , "no_start_watchdog" )
178+ if op .FsType == fstypeAlinas {
179+ // options = append(options, "no_atomic_move", "auto_fallback_nfs")
180+ op .Options = append (op .Options , "no_atomic_move" )
181+ op .Options = addAutoFallbackNFSMountOptions (op .Options )
182+ }
183+ return m .Mount (op .Source , op .Target , op .FsType , op .Options )
184+ }
0 commit comments