@@ -259,16 +259,20 @@ func isSASToken(key string) bool {
259
259
260
260
// GetAuthEnv return <accountName, containerName, authEnv, error>
261
261
func (d * Driver ) GetAuthEnv (ctx context.Context , volumeID , protocol string , attrib , secrets map [string ]string ) (string , string , []string , error ) {
262
+ rgName , accountName , containerName , err := GetContainerInfo (volumeID )
263
+ if err != nil {
264
+ // ignore volumeID parsing error
265
+ klog .Warningf ("parsing volumeID(%s) return with error: %v" , volumeID , err )
266
+ err = nil
267
+ }
268
+
262
269
var (
263
- accountName string
264
270
accountKey string
265
271
accountSasToken string
266
- containerName string
267
272
keyVaultURL string
268
273
keyVaultSecretName string
269
274
keyVaultSecretVersion string
270
275
authEnv []string
271
- err error
272
276
)
273
277
274
278
for k , v := range attrib {
@@ -306,6 +310,7 @@ func (d *Driver) GetAuthEnv(ctx context.Context, volumeID, protocol string, attr
306
310
klog .V (2 ).Infof ("volumeID(%s) authEnv: %s" , volumeID , authEnv )
307
311
308
312
if protocol == nfs {
313
+ // nfs protocol does not need account key, return directly
309
314
return accountName , containerName , authEnv , err
310
315
}
311
316
@@ -324,23 +329,16 @@ func (d *Driver) GetAuthEnv(ctx context.Context, volumeID, protocol string, attr
324
329
}
325
330
} else {
326
331
if len (secrets ) == 0 {
327
- var resourceGroupName string
328
- resourceGroupName , accountName , containerName , err = GetContainerInfo (volumeID )
329
- if err != nil {
330
- return accountName , containerName , authEnv , err
331
- }
332
-
333
- if resourceGroupName == "" {
334
- resourceGroupName = d .cloud .ResourceGroup
335
- }
336
-
337
332
// read from k8s secret first
338
333
accountKey , err = d .GetStorageAccesskeyFromSecret (accountName , attrib [secretNamespaceField ])
339
334
if err != nil {
340
335
klog .V (2 ).Infof ("could not get account(%s) key from secret, error: %v, use cluster identity to get account key instead" , accountName , err )
341
- accountKey , err = d .cloud .GetStorageAccesskey (accountName , resourceGroupName )
336
+ if rgName == "" {
337
+ rgName = d .cloud .ResourceGroup
338
+ }
339
+ accountKey , err = d .cloud .GetStorageAccesskey (accountName , rgName )
342
340
if err != nil {
343
- return accountName , containerName , authEnv , fmt .Errorf ("no key for storage account(%s) under resource group(%s), err %v" , accountName , resourceGroupName , err )
341
+ return accountName , containerName , authEnv , fmt .Errorf ("no key for storage account(%s) under resource group(%s), err %v" , accountName , rgName , err )
344
342
}
345
343
}
346
344
} else {
@@ -385,17 +383,14 @@ func (d *Driver) GetAuthEnv(ctx context.Context, volumeID, protocol string, attr
385
383
// only for e2e testing
386
384
func (d * Driver ) GetStorageAccountAndContainer (ctx context.Context , volumeID string , attrib , secrets map [string ]string ) (string , string , string , string , error ) {
387
385
var (
388
- accountName string
389
- accountKey string
390
- accountSasToken string
391
-
392
- containerName string
393
-
386
+ accountName string
387
+ accountKey string
388
+ accountSasToken string
389
+ containerName string
394
390
keyVaultURL string
395
391
keyVaultSecretName string
396
392
keyVaultSecretVersion string
397
-
398
- err error
393
+ err error
399
394
)
400
395
401
396
for k , v := range attrib {
@@ -430,19 +425,19 @@ func (d *Driver) GetStorageAccountAndContainer(ctx context.Context, volumeID str
430
425
}
431
426
} else {
432
427
if len (secrets ) == 0 {
433
- var resourceGroupName string
434
- resourceGroupName , accountName , containerName , err = GetContainerInfo (volumeID )
428
+ var rgName string
429
+ rgName , accountName , containerName , err = GetContainerInfo (volumeID )
435
430
if err != nil {
436
431
return "" , "" , "" , "" , err
437
432
}
438
433
439
- if resourceGroupName == "" {
440
- resourceGroupName = d .cloud .ResourceGroup
434
+ if rgName == "" {
435
+ rgName = d .cloud .ResourceGroup
441
436
}
442
437
443
- accountKey , err = d .cloud .GetStorageAccesskey (accountName , resourceGroupName )
438
+ accountKey , err = d .cloud .GetStorageAccesskey (accountName , rgName )
444
439
if err != nil {
445
- return "" , "" , "" , "" , fmt .Errorf ("no key for storage account(%s) under resource group(%s), err %v" , accountName , resourceGroupName , err )
440
+ return "" , "" , "" , "" , fmt .Errorf ("no key for storage account(%s) under resource group(%s), err %v" , accountName , rgName , err )
446
441
}
447
442
}
448
443
}
0 commit comments