@@ -333,7 +333,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
333
333
334
334
tags , err := ConvertTagsToMap (customTags )
335
335
if err != nil {
336
- return nil , err
336
+ return nil , status . Errorf ( codes . InvalidArgument , err . Error ())
337
337
}
338
338
339
339
accountOptions := & azure.AccountOptions {
@@ -367,7 +367,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
367
367
// search in cache first
368
368
cache , err := d .accountSearchCache .Get (lockKey , azcache .CacheReadTypeDefault )
369
369
if err != nil {
370
- return nil , err
370
+ return nil , status . Errorf ( codes . Internal , err . Error ())
371
371
}
372
372
if cache != nil {
373
373
accountName = cache .(string )
@@ -415,7 +415,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
415
415
if len (secret ) == 0 && useDataPlaneAPI {
416
416
if accountKey == "" {
417
417
if accountKey , err = d .GetStorageAccesskey (ctx , accountOptions , secret , secretName , secretNamespace ); err != nil {
418
- return nil , fmt .Errorf ("failed to GetStorageAccesskey on account(%s) rg(%s), error: %v" , accountOptions .Name , accountOptions .ResourceGroup , err )
418
+ return nil , status .Errorf (codes . Internal , "failed to GetStorageAccesskey on account(%s) rg(%s), error: %v" , accountOptions .Name , accountOptions .ResourceGroup , err )
419
419
}
420
420
}
421
421
secret = createStorageAccountSecret (accountName , accountKey )
@@ -457,20 +457,20 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
457
457
d .volumeLocks .Release (volName )
458
458
// clean search cache
459
459
if err := d .accountSearchCache .Delete (lockKey ); err != nil {
460
- return nil , err
460
+ return nil , status . Errorf ( codes . Internal , err . Error ())
461
461
}
462
462
// remove the volName from the volMap to stop it matching the same storage account
463
463
d .volMap .Delete (volName )
464
464
return d .CreateVolume (ctx , req )
465
465
}
466
- return nil , fmt .Errorf ("failed to create file share(%s) on account(%s) type(%s) rg(%s) location(%s) size(%d), error: %v" , validFileShareName , account , sku , resourceGroup , location , fileShareSize , err )
466
+ return nil , status .Errorf (codes . Internal , "failed to create file share(%s) on account(%s) type(%s) rg(%s) location(%s) size(%d), error: %v" , validFileShareName , account , sku , resourceGroup , location , fileShareSize , err )
467
467
}
468
468
klog .V (2 ).Infof ("create file share %s on storage account %s successfully" , validFileShareName , accountName )
469
469
470
470
if isDiskFsType (fsType ) && ! strings .HasSuffix (diskName , vhdSuffix ) {
471
471
if accountKey == "" {
472
472
if accountKey , err = d .GetStorageAccesskey (ctx , accountOptions , req .GetSecrets (), secretName , secretNamespace ); err != nil {
473
- return nil , fmt .Errorf ("failed to GetStorageAccesskey on account(%s) rg(%s), error: %v" , accountOptions .Name , accountOptions .ResourceGroup , err )
473
+ return nil , status .Errorf (codes . Internal , "failed to GetStorageAccesskey on account(%s) rg(%s), error: %v" , accountOptions .Name , accountOptions .ResourceGroup , err )
474
474
}
475
475
}
476
476
if fileShareName == "" {
@@ -503,7 +503,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
503
503
if ! useSeretCache {
504
504
if accountKey == "" {
505
505
if accountKey , err = d .GetStorageAccesskey (ctx , accountOptions , req .GetSecrets (), secretName , secretNamespace ); err != nil {
506
- return nil , fmt .Errorf ("failed to GetStorageAccesskey on account(%s) rg(%s), error: %v" , accountOptions .Name , accountOptions .ResourceGroup , err )
506
+ return nil , status .Errorf (codes . Internal , "failed to GetStorageAccesskey on account(%s) rg(%s), error: %v" , accountOptions .Name , accountOptions .ResourceGroup , err )
507
507
}
508
508
}
509
509
storeSecretName , err := d .SetAzureCredentials (ctx , accountName , accountKey , secretName , secretNamespace )
0 commit comments