Skip to content

Commit

Permalink
fix: increase volume cloning timeout and reduce time cost
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhangx committed Jan 31, 2024
1 parent 9fe96e1 commit 5a3c0ff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
5 changes: 5 additions & 0 deletions pkg/blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ type DriverOptions struct {
EnableAznfsMount bool
VolStatsCacheExpireInMinutes int
SasTokenExpirationMinutes int
WaitForAzCopyTimeoutMinutes int
}

func (option *DriverOptions) AddFlags() {
Expand All @@ -188,6 +189,7 @@ func (option *DriverOptions) AddFlags() {
flag.BoolVar(&option.EnableAznfsMount, "enable-aznfs-mount", false, "replace nfs mount with aznfs mount")
flag.IntVar(&option.VolStatsCacheExpireInMinutes, "vol-stats-cache-expire-in-minutes", 10, "The cache expire time in minutes for volume stats cache")
flag.IntVar(&option.SasTokenExpirationMinutes, "sas-token-expiration-minutes", 1440, "sas token expiration minutes during volume cloning")
flag.IntVar(&option.WaitForAzCopyTimeoutMinutes, "wait-for-azcopy-timeout-minutes", 18, "timeout in minutes for waiting for azcopy to finish")
}

// Driver implements all interfaces of CSI drivers
Expand Down Expand Up @@ -226,6 +228,8 @@ type Driver struct {
azcopySasTokenCache azcache.Resource
// sas expiry time for azcopy in volume clone
sasTokenExpirationMinutes int
// timeout in minutes for waiting for azcopy to finish
waitForAzCopyTimeoutMinutes int
// azcopy for provide exec mock for ut
azcopy *util.Azcopy
}
Expand All @@ -248,6 +252,7 @@ func NewDriver(options *DriverOptions, kubeClient kubernetes.Interface, cloud *p
mountPermissions: options.MountPermissions,
enableAznfsMount: options.EnableAznfsMount,
sasTokenExpirationMinutes: options.SasTokenExpirationMinutes,
waitForAzCopyTimeoutMinutes: options.WaitForAzCopyTimeoutMinutes,
azcopy: &util.Azcopy{},
KubeClient: kubeClient,
cloud: cloud,
Expand Down
26 changes: 14 additions & 12 deletions pkg/blob/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ const (

func NewFakeDriver() *Driver {
driverOptions := DriverOptions{
NodeID: fakeNodeID,
DriverName: DefaultDriverName,
BlobfuseProxyEndpoint: "",
EnableBlobfuseProxy: false,
BlobfuseProxyConnTimout: 5,
EnableBlobMockMount: false,
NodeID: fakeNodeID,
DriverName: DefaultDriverName,
BlobfuseProxyEndpoint: "",
EnableBlobfuseProxy: false,
BlobfuseProxyConnTimout: 5,
WaitForAzCopyTimeoutMinutes: 1,
EnableBlobMockMount: false,
}
driver := NewDriver(&driverOptions, nil, &azure.Cloud{})
driver.Name = fakeDriverName
Expand All @@ -79,12 +80,13 @@ func TestNewFakeDriver(t *testing.T) {

func TestNewDriver(t *testing.T) {
driverOptions := DriverOptions{
NodeID: fakeNodeID,
DriverName: DefaultDriverName,
BlobfuseProxyEndpoint: "",
EnableBlobfuseProxy: false,
BlobfuseProxyConnTimout: 5,
EnableBlobMockMount: false,
NodeID: fakeNodeID,
DriverName: DefaultDriverName,
BlobfuseProxyEndpoint: "",
EnableBlobfuseProxy: false,
BlobfuseProxyConnTimout: 5,
WaitForAzCopyTimeoutMinutes: 1,
EnableBlobMockMount: false,
}
driver := NewDriver(&driverOptions, nil, &azure.Cloud{})
fakedriver := NewFakeDriver()
Expand Down
7 changes: 3 additions & 4 deletions pkg/blob/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ const (
SPN = "SPN"
authorizationPermissionMismatch = "AuthorizationPermissionMismatch"

waitForCopyInterval = 5 * time.Second
waitForCopyTimeout = 3 * time.Minute
waitForAzCopyInterval = 2 * time.Second
)

// CreateVolume provisions a volume
Expand Down Expand Up @@ -735,8 +734,8 @@ func (d *Driver) copyBlobContainer(req *csi.CreateVolumeRequest, accountSasToken
return fmt.Errorf("srcContainerName(%s) or dstContainerName(%s) is empty", srcContainerName, dstContainerName)
}

timeAfter := time.After(waitForCopyTimeout)
timeTick := time.Tick(waitForCopyInterval)
timeAfter := time.After(time.Duration(d.waitForAzCopyTimeoutMinutes) * time.Minute)
timeTick := time.Tick(waitForAzCopyInterval)
srcPath := fmt.Sprintf("https://%s.blob.%s/%s%s", accountName, storageEndpointSuffix, srcContainerName, accountSasToken)
dstPath := fmt.Sprintf("https://%s.blob.%s/%s%s", accountName, storageEndpointSuffix, dstContainerName, accountSasToken)

Expand Down

0 comments on commit 5a3c0ff

Please sign in to comment.