@@ -30,6 +30,7 @@ import (
30
30
"google.golang.org/grpc/status"
31
31
32
32
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
33
+ "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage"
33
34
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
34
35
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/sas"
35
36
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service"
@@ -42,6 +43,7 @@ import (
42
43
"k8s.io/utils/pointer"
43
44
44
45
"sigs.k8s.io/blob-csi-driver/pkg/util"
46
+ "sigs.k8s.io/cloud-provider-azure/pkg/azclient/blobcontainerclient"
45
47
azcache "sigs.k8s.io/cloud-provider-azure/pkg/cache"
46
48
"sigs.k8s.io/cloud-provider-azure/pkg/metrics"
47
49
"sigs.k8s.io/cloud-provider-azure/pkg/provider"
@@ -261,7 +263,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
261
263
return nil , status .Errorf (codes .InvalidArgument , "protocol(%s) is not supported, supported protocol list: %v" , protocol , supportedProtocolList )
262
264
}
263
265
if ! isSupportedAccessTier (accessTier ) {
264
- return nil , status .Errorf (codes .InvalidArgument , "accessTier(%s) is not supported, supported AccessTier list: %v" , accessTier , storage .PossibleAccessTierValues ())
266
+ return nil , status .Errorf (codes .InvalidArgument , "accessTier(%s) is not supported, supported AccessTier list: %v" , accessTier , armstorage .PossibleAccessTierValues ())
265
267
}
266
268
267
269
if containerName != "" && containerNamePrefix != "" {
@@ -275,7 +277,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
275
277
if strings .EqualFold (networkEndpointType , privateEndpoint ) {
276
278
createPrivateEndpoint = pointer .BoolPtr (true )
277
279
}
278
- accountKind := string (storage .KindStorageV2 )
280
+ accountKind := string (armstorage .KindStorageV2 )
279
281
if isNFSProtocol (protocol ) {
280
282
isHnsEnabled = pointer .Bool (true )
281
283
enableNfsV3 = pointer .Bool (true )
@@ -293,11 +295,11 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
293
295
}
294
296
295
297
if strings .HasPrefix (strings .ToLower (storageAccountType ), "premium" ) {
296
- accountKind = string (storage .KindBlockBlobStorage )
298
+ accountKind = string (armstorage .KindBlockBlobStorage )
297
299
}
298
300
if IsAzureStackCloud (d .cloud ) {
299
- accountKind = string (storage .KindStorage )
300
- if storageAccountType != "" && storageAccountType != string (storage . SkuNameStandardLRS ) && storageAccountType != string (storage . SkuNamePremiumLRS ) {
301
+ accountKind = string (armstorage .KindStorage )
302
+ if storageAccountType != "" && storageAccountType != string (armstorage . SKUNameStandardLRS ) && storageAccountType != string (armstorage . SKUNamePremiumLRS ) {
301
303
return nil , status .Errorf (codes .InvalidArgument , fmt .Sprintf ("Invalid skuName value: %s, as Azure Stack only supports %s and %s Storage Account types." , storageAccountType , storage .SkuNamePremiumLRS , storage .SkuNameStandardLRS ))
302
304
}
303
305
}
@@ -449,7 +451,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
449
451
}
450
452
}
451
453
452
- secretName , err := setAzureCredentials (ctx , d .cloud . KubeClient , accountName , accountKey , secretNamespace )
454
+ secretName , err := setAzureCredentials (ctx , d .KubeClient , accountName , accountKey , secretNamespace )
453
455
if err != nil {
454
456
return nil , status .Errorf (codes .Internal , "failed to store storage account key: %v" , err )
455
457
}
@@ -569,8 +571,12 @@ func (d *Driver) ValidateVolumeCapabilities(ctx context.Context, req *csi.Valida
569
571
if resourceGroupName == "" {
570
572
resourceGroupName = d .cloud .ResourceGroup
571
573
}
572
- blobContainer , retryErr := d .cloud .BlobClient .GetContainer (ctx , subsID , resourceGroupName , accountName , containerName )
573
- err = retryErr .Error ()
574
+ blobClient , err := d .clientFactory .GetBlobContainerClientForSub (subsID )
575
+ if err != nil {
576
+ return nil , status .Error (codes .Internal , err .Error ())
577
+ }
578
+
579
+ blobContainer , err := blobClient .Get (ctx , resourceGroupName , accountName , containerName )
574
580
if err != nil {
575
581
return nil , status .Error (codes .Internal , err .Error ())
576
582
}
@@ -678,12 +684,17 @@ func (d *Driver) CreateBlobContainer(ctx context.Context, subsID, resourceGroupN
678
684
}
679
685
_ , err = container .CreateIfNotExists (& azstorage.CreateContainerOptions {Access : azstorage .ContainerAccessTypePrivate })
680
686
} else {
681
- blobContainer := storage .BlobContainer {
682
- ContainerProperties : & storage .ContainerProperties {
683
- PublicAccess : storage . PublicAccessNone ,
687
+ blobContainer := armstorage .BlobContainer {
688
+ ContainerProperties : & armstorage .ContainerProperties {
689
+ PublicAccess : to . Ptr ( armstorage . PublicAccessNone ) ,
684
690
},
685
691
}
686
- err = d .cloud .BlobClient .CreateContainer (ctx , subsID , resourceGroupName , accountName , containerName , blobContainer ).Error ()
692
+ var blobClient blobcontainerclient.Interface
693
+ blobClient , err = d .clientFactory .GetBlobContainerClientForSub (subsID )
694
+ if err != nil {
695
+ return true , err
696
+ }
697
+ _ , err = blobClient .CreateContainer (ctx , resourceGroupName , accountName , containerName , blobContainer )
687
698
}
688
699
if err != nil {
689
700
if strings .Contains (err .Error (), containerBeingDeletedDataplaneAPIError ) ||
@@ -710,7 +721,12 @@ func (d *Driver) DeleteBlobContainer(ctx context.Context, subsID, resourceGroupN
710
721
}
711
722
_ , err = container .DeleteIfExists (nil )
712
723
} else {
713
- err = d .cloud .BlobClient .DeleteContainer (ctx , subsID , resourceGroupName , accountName , containerName ).Error ()
724
+ var blobClient blobcontainerclient.Interface
725
+ blobClient , err = d .clientFactory .GetBlobContainerClientForSub (subsID )
726
+ if err != nil {
727
+ return true , err
728
+ }
729
+ err = blobClient .DeleteContainer (ctx , resourceGroupName , accountName , containerName )
714
730
}
715
731
if err != nil {
716
732
if strings .Contains (err .Error (), containerBeingDeletedDataplaneAPIError ) ||
0 commit comments