@@ -21,14 +21,18 @@ import (
2121 "fmt"
2222 "net"
2323 "strings"
24+ "time"
2425
2526 grpcprom "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
2627 "google.golang.org/grpc"
2728 "k8s.io/klog/v2"
2829 mount_utils "k8s.io/mount-utils"
2930 mount_azurefile "sigs.k8s.io/azurefile-csi-driver/pkg/azurefile-proxy/pb"
31+ volumehelper "sigs.k8s.io/azurefile-csi-driver/pkg/util"
3032)
3133
34+ const mountTimeoutInSec = 90
35+
3236type MountServer struct {
3337 mount_azurefile.UnimplementedMountServiceServer
3438
@@ -55,8 +59,14 @@ func (server *MountServer) MountAzureFile(_ context.Context,
5559 sensitiveOptions := req .GetSensitiveOptions ()
5660 klog .V (2 ).Infof ("received mount request: source: %s, target: %s, fstype: %s, options: %s" , source , target , fstype , strings .Join (options , "," ))
5761
58- err = server .mounter .MountSensitive (source , target , fstype , options , sensitiveOptions )
59- if err != nil {
62+ execFunc := func () error {
63+ return server .mounter .MountSensitive (source , target , fstype , options , sensitiveOptions )
64+ }
65+ timeoutFunc := func () error {
66+ return fmt .Errorf ("mount operation timed out after 90 seconds: source=%s, target=%s" , source , target )
67+ }
68+
69+ if err = volumehelper .WaitUntilTimeout (mountTimeoutInSec * time .Second , execFunc , timeoutFunc ); err != nil {
6070 klog .Error ("azurefile mount failed: with error:" , err .Error ())
6171 return nil , fmt .Errorf ("azurefile mount failed: %v" , err )
6272 }
0 commit comments