Skip to content

fix: support createFolderIfNotExist for NFS protocol#3052

Closed
andyzhangx wants to merge 1 commit intomasterfrom
fix/nfs-create-folder
Closed

fix: support createFolderIfNotExist for NFS protocol#3052
andyzhangx wants to merge 1 commit intomasterfrom
fix/nfs-create-folder

Conversation

@andyzhangx
Copy link
Copy Markdown
Member

Problem

createFolderIfNotExist does not work when using NFS protocol (#3041).

Root cause: In NFS mode, GetAccountInfo returns early without retrieving the storage account key (NFS doesn't need one for mounting). However, createFolderIfNotExists calls newAzureFileClient which requires the account key to create a data plane client. With an empty key, the client creation fails and folder creation silently doesn't happen.

Fix

For NFS protocol, use a different approach to create folders:

  1. Mount the NFS share root to a temporary directory
  2. Create the folder path using os.MkdirAll
  3. Unmount the temporary mount
  4. Proceed with the normal mount (which includes the folderName in the source path)

This avoids the need for an account key entirely, leveraging the fact that NFS mounts don't require storage account authentication.

Changes

  • nodeserver.go: Branch on protocol in the createFolderIfNotExist logic — use data plane client for SMB, use temp mount + MkdirAll for NFS
  • nodeserver.go: Add createFolderOnNfsShare method

Fixes #3041

When using NFS protocol, GetAccountInfo returns early without an
account key since NFS doesn't need one. However, createFolderIfNotExists
requires an account key to create a data plane client, so it silently
fails for NFS shares.

Fix: For NFS, mount the share root to a temporary directory, create
the folder using os.MkdirAll, then unmount. This avoids the need for
an account key entirely.

Fixes: #3041
@k8s-ci-robot k8s-ci-robot requested review from cvvz and gnufied April 5, 2026 03:48
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andyzhangx

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 5, 2026
@andyzhangx andyzhangx closed this Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Question: Is there any plan to support automatic subdirectory (folderName) creation like nfs-csi-driver?

2 participants