Skip to content

Commit 0e4f564

Browse files
authored
Merge pull request #1226 from andyzhangx/increase-azcopy-timeout
fix: increase volume cloning timeout and reduce time cost
2 parents 5815ce8 + 2c2344d commit 0e4f564

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

pkg/blob/blob.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ type DriverOptions struct {
176176
EnableAznfsMount bool
177177
VolStatsCacheExpireInMinutes int
178178
SasTokenExpirationMinutes int
179+
WaitForAzCopyTimeoutMinutes int
179180
EnableVolumeMountGroup bool
180181
FSGroupChangePolicy string
181182
}
@@ -195,6 +196,7 @@ func (option *DriverOptions) AddFlags() {
195196
flag.BoolVar(&option.EnableAznfsMount, "enable-aznfs-mount", false, "replace nfs mount with aznfs mount")
196197
flag.IntVar(&option.VolStatsCacheExpireInMinutes, "vol-stats-cache-expire-in-minutes", 10, "The cache expire time in minutes for volume stats cache")
197198
flag.IntVar(&option.SasTokenExpirationMinutes, "sas-token-expiration-minutes", 1440, "sas token expiration minutes during volume cloning")
199+
flag.IntVar(&option.WaitForAzCopyTimeoutMinutes, "wait-for-azcopy-timeout-minutes", 18, "timeout in minutes for waiting for azcopy to finish")
198200
flag.BoolVar(&option.EnableVolumeMountGroup, "enable-volume-mount-group", true, "indicates whether enabling VOLUME_MOUNT_GROUP")
199201
flag.StringVar(&option.FSGroupChangePolicy, "fsgroup-change-policy", "", "indicates how the volume's ownership will be changed by the driver, OnRootMismatch is the default value")
200202
}
@@ -239,6 +241,8 @@ type Driver struct {
239241
azcopySasTokenCache azcache.Resource
240242
// sas expiry time for azcopy in volume clone
241243
sasTokenExpirationMinutes int
244+
// timeout in minutes for waiting for azcopy to finish
245+
waitForAzCopyTimeoutMinutes int
242246
// azcopy for provide exec mock for ut
243247
azcopy *util.Azcopy
244248
}
@@ -261,6 +265,7 @@ func NewDriver(options *DriverOptions, kubeClient kubernetes.Interface, cloud *p
261265
mountPermissions: options.MountPermissions,
262266
enableAznfsMount: options.EnableAznfsMount,
263267
sasTokenExpirationMinutes: options.SasTokenExpirationMinutes,
268+
waitForAzCopyTimeoutMinutes: options.WaitForAzCopyTimeoutMinutes,
264269
fsGroupChangePolicy: options.FSGroupChangePolicy,
265270
azcopy: &util.Azcopy{},
266271
KubeClient: kubeClient,

pkg/blob/blob_test.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ const (
5050

5151
func NewFakeDriver() *Driver {
5252
driverOptions := DriverOptions{
53-
NodeID: fakeNodeID,
54-
DriverName: DefaultDriverName,
55-
BlobfuseProxyEndpoint: "",
56-
EnableBlobfuseProxy: false,
57-
BlobfuseProxyConnTimout: 5,
58-
EnableBlobMockMount: false,
53+
NodeID: fakeNodeID,
54+
DriverName: DefaultDriverName,
55+
BlobfuseProxyEndpoint: "",
56+
EnableBlobfuseProxy: false,
57+
BlobfuseProxyConnTimout: 5,
58+
WaitForAzCopyTimeoutMinutes: 1,
59+
EnableBlobMockMount: false,
5960
}
6061
driver := NewDriver(&driverOptions, nil, &azure.Cloud{})
6162
driver.Name = fakeDriverName
@@ -79,12 +80,13 @@ func TestNewFakeDriver(t *testing.T) {
7980

8081
func TestNewDriver(t *testing.T) {
8182
driverOptions := DriverOptions{
82-
NodeID: fakeNodeID,
83-
DriverName: DefaultDriverName,
84-
BlobfuseProxyEndpoint: "",
85-
EnableBlobfuseProxy: false,
86-
BlobfuseProxyConnTimout: 5,
87-
EnableBlobMockMount: false,
83+
NodeID: fakeNodeID,
84+
DriverName: DefaultDriverName,
85+
BlobfuseProxyEndpoint: "",
86+
EnableBlobfuseProxy: false,
87+
BlobfuseProxyConnTimout: 5,
88+
WaitForAzCopyTimeoutMinutes: 1,
89+
EnableBlobMockMount: false,
8890
}
8991
driver := NewDriver(&driverOptions, nil, &azure.Cloud{})
9092
fakedriver := NewFakeDriver()

pkg/blob/controllerserver.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ const (
6262
SPN = "SPN"
6363
authorizationPermissionMismatch = "AuthorizationPermissionMismatch"
6464

65-
waitForCopyInterval = 5 * time.Second
66-
waitForCopyTimeout = 3 * time.Minute
65+
waitForAzCopyInterval = 2 * time.Second
6766
)
6867

6968
// CreateVolume provisions a volume
@@ -757,8 +756,8 @@ func (d *Driver) copyBlobContainer(req *csi.CreateVolumeRequest, accountSasToken
757756
return fmt.Errorf("srcContainerName(%s) or dstContainerName(%s) is empty", srcContainerName, dstContainerName)
758757
}
759758

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

0 commit comments

Comments
 (0)