From 092a497e1261e2c7e355e37a56eac56111a0916d Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Wed, 24 Dec 2025 07:16:38 +0000 Subject: [PATCH 1/2] fix: add mount timeout in NFS EiT mount fix fix fix --- pkg/azurefile-proxy/server/server.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/azurefile-proxy/server/server.go b/pkg/azurefile-proxy/server/server.go index 3a7e33f30a..50a9a2426d 100644 --- a/pkg/azurefile-proxy/server/server.go +++ b/pkg/azurefile-proxy/server/server.go @@ -21,14 +21,18 @@ import ( "fmt" "net" "strings" + "time" grpcprom "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus" "google.golang.org/grpc" "k8s.io/klog/v2" mount_utils "k8s.io/mount-utils" mount_azurefile "sigs.k8s.io/azurefile-csi-driver/pkg/azurefile-proxy/pb" + volumehelper "sigs.k8s.io/azurefile-csi-driver/pkg/util" ) +const mountTimeoutInSec = 90 + type MountServer struct { mount_azurefile.UnimplementedMountServiceServer @@ -55,8 +59,14 @@ func (server *MountServer) MountAzureFile(_ context.Context, sensitiveOptions := req.GetSensitiveOptions() klog.V(2).Infof("received mount request: source: %s, target: %s, fstype: %s, options: %s", source, target, fstype, strings.Join(options, ",")) - err = server.mounter.MountSensitive(source, target, fstype, options, sensitiveOptions) - if err != nil { + execFunc := func() error { + return server.mounter.MountSensitive(source, target, fstype, options, sensitiveOptions) + } + timeoutFunc := func() error { + return fmt.Errorf("mount operation timed out after %d seconds: source=%s, target=%s", mountTimeoutInSec, source, target) + } + + if err = volumehelper.WaitUntilTimeout(mountTimeoutInSec*time.Second, execFunc, timeoutFunc); err != nil { klog.Error("azurefile mount failed: with error:", err.Error()) return nil, fmt.Errorf("azurefile mount failed: %v", err) } From 5677040d4847926cade667e1b9f53051938bfbf9 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Wed, 24 Dec 2025 14:00:12 +0000 Subject: [PATCH 2/2] fix: add mount timeout in NFS EiT mount inside csi driver mount fix fix fix fix fix --- pkg/azurefile-proxy/server/server.go | 7 ++++--- pkg/azurefile/azurefile.go | 2 ++ pkg/azurefile/nodeserver.go | 20 ++++++++++++++------ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/pkg/azurefile-proxy/server/server.go b/pkg/azurefile-proxy/server/server.go index 50a9a2426d..c8221a3e1f 100644 --- a/pkg/azurefile-proxy/server/server.go +++ b/pkg/azurefile-proxy/server/server.go @@ -27,12 +27,11 @@ import ( "google.golang.org/grpc" "k8s.io/klog/v2" mount_utils "k8s.io/mount-utils" + "sigs.k8s.io/azurefile-csi-driver/pkg/azurefile" mount_azurefile "sigs.k8s.io/azurefile-csi-driver/pkg/azurefile-proxy/pb" volumehelper "sigs.k8s.io/azurefile-csi-driver/pkg/util" ) -const mountTimeoutInSec = 90 - type MountServer struct { mount_azurefile.UnimplementedMountServiceServer @@ -62,11 +61,13 @@ func (server *MountServer) MountAzureFile(_ context.Context, execFunc := func() error { return server.mounter.MountSensitive(source, target, fstype, options, sensitiveOptions) } + + mountTimeoutInSec := azurefile.MountTimeoutInSec - 2 timeoutFunc := func() error { return fmt.Errorf("mount operation timed out after %d seconds: source=%s, target=%s", mountTimeoutInSec, source, target) } - if err = volumehelper.WaitUntilTimeout(mountTimeoutInSec*time.Second, execFunc, timeoutFunc); err != nil { + if err = volumehelper.WaitUntilTimeout(time.Duration(mountTimeoutInSec)*time.Second, execFunc, timeoutFunc); err != nil { klog.Error("azurefile mount failed: with error:", err.Error()) return nil, fmt.Errorf("azurefile mount failed: %v", err) } diff --git a/pkg/azurefile/azurefile.go b/pkg/azurefile/azurefile.go index 0c7e02bc17..f4fe9faf4b 100644 --- a/pkg/azurefile/azurefile.go +++ b/pkg/azurefile/azurefile.go @@ -212,6 +212,8 @@ const ( standardv2 = "standardv2" premiumv2 = "premiumv2" + + MountTimeoutInSec = 90 ) var ( diff --git a/pkg/azurefile/nodeserver.go b/pkg/azurefile/nodeserver.go index fd43ec6e4b..3721969616 100644 --- a/pkg/azurefile/nodeserver.go +++ b/pkg/azurefile/nodeserver.go @@ -458,8 +458,10 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe execFunc := func() error { return SMBMount(d.mounter, source, cifsMountPath, mountFsType, mountOptions, sensitiveMountOptions) } - timeoutFunc := func() error { return fmt.Errorf("time out") } - if err := volumehelper.WaitUntilTimeout(90*time.Second, execFunc, timeoutFunc); err != nil { + timeoutFunc := func() error { + return fmt.Errorf("mount operation timed out after %d seconds: source=%s, target=%s", MountTimeoutInSec, source, cifsMountPath) + } + if err := volumehelper.WaitUntilTimeout(MountTimeoutInSec*time.Second, execFunc, timeoutFunc); err != nil { var helpLinkMsg string if d.appendMountErrorHelpLink { helpLinkMsg = "\nPlease refer to http://aka.ms/filemounterror for possible causes and solutions for mount errors." @@ -772,7 +774,6 @@ func (d *Driver) mountWithProxy(ctx context.Context, source, target, fsType stri klog.Error("failed to close connection to azurefile proxy:", err) } }() - klog.V(2).Infof("connected to azurefile proxy successfully") mountClient := NewMountClient(conn) mountreq := mount_azurefile.MountAzureFileRequest{ @@ -783,12 +784,19 @@ func (d *Driver) mountWithProxy(ctx context.Context, source, target, fsType stri SensitiveOptions: sensitiveMountOptions, } klog.V(2).Infof("begin to mount with azurefile proxy, source: %s, target: %s, fstype: %s, mountOptions: %v", source, target, fsType, options) - _, err = mountClient.service.MountAzureFile(ctx, &mountreq) - if err != nil { - klog.Error("GRPC call returned with an error:", err) + newCtx, cancel := context.WithTimeout(ctx, MountTimeoutInSec*time.Second) + defer cancel() + execFunc := func() error { + _, err := mountClient.service.MountAzureFile(newCtx, &mountreq) return err } + timeoutFunc := func() error { + return fmt.Errorf("mount with azurefile proxy timed out after %d seconds: source=%s, target=%s", MountTimeoutInSec, source, target) + } + if err = volumehelper.WaitUntilTimeout(MountTimeoutInSec*time.Second, execFunc, timeoutFunc); err != nil { + klog.Error("GRPC call returned with an error:", err) + } return err }