Skip to content

Commit d83e3f2

Browse files
committed
fix: GetAzcopyJob check actual destination container name
1 parent 6544a40 commit d83e3f2

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

pkg/blob/controllerserver.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,10 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
8484
return nil, status.Error(codes.InvalidArgument, err.Error())
8585
}
8686

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-
9887
volSizeBytes := int64(req.GetCapacityRange().GetRequiredBytes())
9988
requestGiB := int(util.RoundUpGiB(volSizeBytes))
10089

90+
volContentSource := req.GetVolumeContentSource()
10191
secrets := req.GetSecrets()
10292

10393
// Parameters
@@ -359,6 +349,17 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
359349
GetLatestAccountKey: getLatestAccountKey,
360350
}
361351

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+
362363
// Telemetry
363364

364365
var volumeID string
@@ -379,6 +380,16 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
379380

380381
// Volume Source
381382

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+
382393
var srcAzcopyAuthEnv []string
383394
var srcSubscriptionID, srcResourceGroupName, srcAccountName, srcContainerName, srcPath, srcAccountSASToken string
384395
if volContentSource != nil {
@@ -469,17 +480,6 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
469480

470481
// Blob Container
471482

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-
}
483483
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)
484484
if err := d.CreateBlobContainer(ctx, subsID, resourceGroup, accountName, validContainerName, secrets); err != nil {
485485
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

Comments
 (0)