@@ -84,20 +84,10 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
84
84
return nil , status .Error (codes .InvalidArgument , err .Error ())
85
85
}
86
86
87
- volContentSource := req .GetVolumeContentSource ()
88
- if acquired := d .volumeLocks .TryAcquire (volName ); ! acquired {
89
- // logging the job status if it's volume cloning
90
- if volContentSource != nil {
91
- jobState , percent , err := d .azcopy .GetAzcopyJob (volName , []string {})
92
- return nil , status .Errorf (codes .Aborted , volumeOperationAlreadyExistsWithAzcopyFmt , volName , jobState , percent , err )
93
- }
94
- return nil , status .Errorf (codes .Aborted , volumeOperationAlreadyExistsFmt , volName )
95
- }
96
- defer d .volumeLocks .Release (volName )
97
-
98
87
volSizeBytes := int64 (req .GetCapacityRange ().GetRequiredBytes ())
99
88
requestGiB := int (util .RoundUpGiB (volSizeBytes ))
100
89
90
+ volContentSource := req .GetVolumeContentSource ()
101
91
secrets := req .GetSecrets ()
102
92
103
93
// Parameters
@@ -359,6 +349,17 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
359
349
GetLatestAccountKey : getLatestAccountKey ,
360
350
}
361
351
352
+ containerName = replaceWithMap (containerName , containerNameReplaceMap )
353
+ validContainerName := containerName
354
+ if validContainerName == "" {
355
+ validContainerName = volName
356
+ if containerNamePrefix != "" {
357
+ validContainerName = containerNamePrefix + "-" + volName
358
+ }
359
+ validContainerName = getValidContainerName (validContainerName , protocol )
360
+ setKeyValueInMap (parameters , containerNameField , validContainerName )
361
+ }
362
+
362
363
// Telemetry
363
364
364
365
var volumeID string
@@ -379,6 +380,16 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
379
380
380
381
// Volume Source
381
382
383
+ if acquired := d .volumeLocks .TryAcquire (volName ); ! acquired {
384
+ // logging the job status if it's volume cloning
385
+ if volContentSource != nil {
386
+ jobState , percent , err := d .azcopy .GetAzcopyJob (validContainerName , []string {})
387
+ return nil , status .Errorf (codes .Aborted , volumeOperationAlreadyExistsWithAzcopyFmt , volName , jobState , percent , err )
388
+ }
389
+ return nil , status .Errorf (codes .Aborted , volumeOperationAlreadyExistsFmt , volName )
390
+ }
391
+ defer d .volumeLocks .Release (volName )
392
+
382
393
var srcAzcopyAuthEnv []string
383
394
var srcSubscriptionID , srcResourceGroupName , srcAccountName , srcContainerName , srcPath , srcAccountSASToken string
384
395
if volContentSource != nil {
@@ -469,17 +480,6 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
469
480
470
481
// Blob Container
471
482
472
- // replace pv/pvc name namespace metadata in subDir
473
- containerName = replaceWithMap (containerName , containerNameReplaceMap )
474
- validContainerName := containerName
475
- if validContainerName == "" {
476
- validContainerName = volName
477
- if containerNamePrefix != "" {
478
- validContainerName = containerNamePrefix + "-" + volName
479
- }
480
- validContainerName = getValidContainerName (validContainerName , protocol )
481
- setKeyValueInMap (parameters , containerNameField , validContainerName )
482
- }
483
483
klog .V (2 ).Infof ("begin to create container(%s) on account(%s) type(%s) subsID(%s) rg(%s) location(%s) size(%d)" , validContainerName , accountName , storageAccountType , subsID , resourceGroup , location , requestGiB )
484
484
if err := d .CreateBlobContainer (ctx , subsID , resourceGroup , accountName , validContainerName , secrets ); err != nil {
485
485
return nil , status .Errorf (codes .Internal , "failed to create container(%s) on account(%s) type(%s) rg(%s) location(%s) size(%d), error: %v" , validContainerName , accountName , storageAccountType , resourceGroup , location , requestGiB , err )
0 commit comments