Skip to content

Commit 423fb53

Browse files
committed
fix: fetch account key for NFS when createFolderIfNotExist is set
When using NFS protocol with createFolderIfNotExist and folderName, GetAccountInfo previously returned early without fetching the account key. This caused createFolderIfNotExists to silently fail because newAzureFileClient requires the account key for data plane operations. Fix: Skip the NFS early-return in GetAccountInfo when both createFolderIfNotExist=true and folderName is set, so the account key is retrieved and the data plane API can create the folder. Fixes: #3041
1 parent e0d2b98 commit 423fb53

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pkg/azurefile/azurefile.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,21 @@ func (d *Driver) GetAccountInfo(ctx context.Context, volumeID string, secrets, r
880880
}
881881
if protocol == nfs && fileShareName != "" {
882882
// nfs protocol does not need account key, return directly
883-
return rgName, accountName, accountKey, fileShareName, diskName, subsID, tenantID, tokenFilePath, err
883+
// unless createFolderIfNotExist is set with a folderName, which requires account key for data plane API
884+
var needAccountKey bool
885+
var hasFolder bool
886+
for k, v := range reqContext {
887+
switch strings.ToLower(k) {
888+
case createFolderIfNotExistField:
889+
needAccountKey = strings.EqualFold(v, trueValue)
890+
case folderNameField:
891+
hasFolder = v != ""
892+
}
893+
}
894+
if !needAccountKey || !hasFolder {
895+
return rgName, accountName, accountKey, fileShareName, diskName, subsID, tenantID, tokenFilePath, err
896+
}
897+
klog.V(2).Infof("NFS protocol with createFolderIfNotExist, fetching account key for data plane API")
884898
}
885899

886900
if secretNamespace == "" {

0 commit comments

Comments
 (0)