@@ -1374,20 +1374,12 @@ func isKataNode(ctx context.Context, nodeID, confidentialContainerLabel string,
13741374// createFolderIfNotExists creates a folder in Azure File Share if it doesn't already exist
13751375// This function handles nested paths by creating each directory level recursively
13761376func (d * Driver ) createFolderIfNotExists (ctx context.Context , accountName , accountKey , fileShareName , folderName , storageEndpointSuffix string ) error {
1377- // Create Azure File service client
1378- credential , err := service .NewSharedKeyCredential (accountName , accountKey )
1379- if err != nil {
1380- return fmt .Errorf ("NewSharedKeyCredential(%s) failed with error: %v" , accountName , err )
1377+ fileClient , err := newAzureFileClient (accountName , accountKey , storageEndpointSuffix )
1378+ if err != nil || fileClient .(* azureFileDataplaneClient ).Client == nil {
1379+ return fmt .Errorf ("create Azure File client(%s) failed: %v" , accountName , err )
13811380 }
13821381
1383- serviceURL := getFileServiceURL (accountName , storageEndpointSuffix )
1384- serviceClient , err := service .NewClientWithSharedKeyCredential (serviceURL , credential , nil )
1385- if err != nil {
1386- return fmt .Errorf ("NewClientWithSharedKeyCredential(%s) failed with error: %v" , serviceURL , err )
1387- }
1388-
1389- // Get share client
1390- shareClient := serviceClient .NewShareClient (fileShareName )
1382+ shareClient := fileClient .(* azureFileDataplaneClient ).Client .NewShareClient (fileShareName )
13911383
13921384 // Performance optimization: First check if the complete directory structure already exists
13931385 // This is the most common case and avoids unnecessary recursive checking
@@ -1426,8 +1418,7 @@ func (d *Driver) createFolderIfNotExists(ctx context.Context, accountName, accou
14261418 directoryClient := shareClient .NewDirectoryClient (currentPath )
14271419
14281420 // Check if directory already exists by trying to get its properties
1429- _ , err = directoryClient .GetProperties (ctx , nil )
1430- if err == nil {
1421+ if _ , err = directoryClient .GetProperties (ctx , nil ); err == nil {
14311422 // Directory already exists, continue to next level
14321423 klog .V (4 ).Infof ("Directory %s already exists in share %s" , currentPath , fileShareName )
14331424 continue
@@ -1441,8 +1432,7 @@ func (d *Driver) createFolderIfNotExists(ctx context.Context, accountName, accou
14411432 }
14421433
14431434 // Create the directory at this level
1444- _ , err = directoryClient .Create (ctx , nil )
1445- if err != nil {
1435+ if _ , err = directoryClient .Create (ctx , nil ); err != nil {
14461436 var respErr * azcore.ResponseError
14471437 if errors .As (err , & respErr ) && respErr .StatusCode == 409 {
14481438 // Directory already exists (race condition), which is fine
0 commit comments