Skip to content

Commit 47b9656

Browse files
andyzhangxk8s-infra-cherrypick-robot
authored andcommitted
feat: allow multiple subnets in updating service endpoints
1 parent 74408ab commit 47b9656

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

docs/driver-parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ isHnsEnabled | enable `Hierarchical namespace` for Azure DataLake storage accoun
4747
mountPermissions | mounted folder permissions. The default is `0777`, if set as `0`, driver will not perform `chmod` after mount | `0777` | No |
4848
vnetResourceGroup | specify vnet resource group where virtual network is | existing resource group name | No | if empty, driver will use the `vnetResourceGroup` value in azure cloud config file
4949
vnetName | virtual network name | existing virtual network name | No | if empty, driver will use the `vnetName` value in azure cloud config file
50-
subnetName | subnet name | existing subnet name of the agent node | No | if empty, driver will use the `subnetName` value in azure cloud config file
50+
subnetName | subnet name | existing subnet name(s) of the agent node, if you want to update service endpoints on multiple subnets, separate them using a comma (`,`) | No | if empty, driver will use the `subnetName` value in azure cloud config file
5151
softDeleteBlobs | Enable [soft delete for blobs](https://learn.microsoft.com/en-us/azure/storage/blobs/soft-delete-blob-overview), specify the days to retain deleted blobs | "7" | No | Soft Delete Blobs is disabled if empty
5252
softDeleteContainers | Enable [soft delete for containers](https://learn.microsoft.com/en-us/azure/storage/blobs/soft-delete-container-overview), specify the days to retain deleted containers | "7" | No | Soft Delete Containers is disabled if empty
5353
enableBlobVersioning | Enable [blob versioning](https://learn.microsoft.com/en-us/azure/storage/blobs/versioning-overview), can't enabled when `protocol` is `nfs` or `isHnsEnabled` is `true` | `true`,`false` | No | versioning for blobs is disabled if empty

pkg/blob/controllerserver.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
266266

267267
enableHTTPSTrafficOnly := true
268268
if strings.EqualFold(networkEndpointType, privateEndpoint) {
269+
if strings.Contains(subnetName, ",") {
270+
return nil, status.Errorf(codes.InvalidArgument, "subnetName(%s) can only contain one subnet for private endpoint", subnetName)
271+
}
269272
createPrivateEndpoint = pointer.BoolPtr(true)
270273
}
271274
accountKind := string(storage.KindStorageV2)
@@ -276,11 +279,15 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
276279
storeAccountKey = false
277280
if !pointer.BoolDeref(createPrivateEndpoint, false) {
278281
// set VirtualNetworkResourceIDs for storage account firewall setting
279-
vnetResourceID := d.getSubnetResourceID(vnetResourceGroup, vnetName, subnetName)
280-
klog.V(2).Infof("set vnetResourceID(%s) for NFS protocol", vnetResourceID)
281-
vnetResourceIDs = []string{vnetResourceID}
282-
if err := d.updateSubnetServiceEndpoints(ctx, vnetResourceGroup, vnetName, subnetName); err != nil {
283-
return nil, status.Errorf(codes.Internal, "update service endpoints failed with error: %v", err)
282+
subnets := strings.Split(subnetName, ",")
283+
for _, subnet := range subnets {
284+
subnet = strings.TrimSpace(subnet)
285+
vnetResourceID := d.getSubnetResourceID(vnetResourceGroup, vnetName, subnet)
286+
klog.V(2).Infof("set vnetResourceID(%s) for NFS protocol", vnetResourceID)
287+
vnetResourceIDs = []string{vnetResourceID}
288+
if err := d.updateSubnetServiceEndpoints(ctx, vnetResourceGroup, vnetName, subnet); err != nil {
289+
return nil, status.Errorf(codes.Internal, "update service endpoints failed with error: %v", err)
290+
}
284291
}
285292
}
286293
}

pkg/blob/controllerserver_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,30 @@ func TestCreateVolume(t *testing.T) {
440440
}
441441
},
442442
},
443+
{
444+
name: "invalid privateEndpoint and subnetName combination",
445+
testFunc: func(t *testing.T) {
446+
d := NewFakeDriver()
447+
mp := map[string]string{
448+
networkEndpointTypeField: "privateendpoint",
449+
subnetNameField: "subnet1,subnet2",
450+
}
451+
req := &csi.CreateVolumeRequest{
452+
Name: "unit-test",
453+
VolumeCapabilities: stdVolumeCapabilities,
454+
Parameters: mp,
455+
}
456+
d.Cap = []*csi.ControllerServiceCapability{
457+
controllerServiceCapability,
458+
}
459+
460+
expectedErr := status.Errorf(codes.InvalidArgument, "subnetName(subnet1,subnet2) can only contain one subnet for private endpoint")
461+
_, err := d.CreateVolume(context.Background(), req)
462+
if !reflect.DeepEqual(err, expectedErr) {
463+
t.Errorf("Unexpected error: %v", err)
464+
}
465+
},
466+
},
443467
{
444468
name: "NFS not supported by cross subscription",
445469
testFunc: func(t *testing.T) {

0 commit comments

Comments
 (0)