Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions pkg/azurefile-proxy/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ 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"
"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"
)

type MountServer struct {
Expand Down Expand Up @@ -55,8 +58,16 @@ 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)
}

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(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)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/azurefile/azurefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ const (

standardv2 = "standardv2"
premiumv2 = "premiumv2"

MountTimeoutInSec = 90
)

var (
Expand Down
20 changes: 14 additions & 6 deletions pkg/azurefile/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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{
Expand All @@ -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
}

Expand Down
Loading