Skip to content

Commit abeb7ad

Browse files
andyzhangxk8s-infra-cherrypick-robot
authored andcommitted
feat: allow multiple subnets in updating service endpoints
1 parent 300c292 commit abeb7ad

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
@@ -274,6 +274,9 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
274274

275275
enableHTTPSTrafficOnly := true
276276
if strings.EqualFold(networkEndpointType, privateEndpoint) {
277+
if strings.Contains(subnetName, ",") {
278+
return nil, status.Errorf(codes.InvalidArgument, "subnetName(%s) can only contain one subnet for private endpoint", subnetName)
279+
}
277280
createPrivateEndpoint = pointer.BoolPtr(true)
278281
}
279282
accountKind := string(armstorage.KindStorageV2)
@@ -284,11 +287,15 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
284287
storeAccountKey = false
285288
if !pointer.BoolDeref(createPrivateEndpoint, false) {
286289
// set VirtualNetworkResourceIDs for storage account firewall setting
287-
vnetResourceID := d.getSubnetResourceID(vnetResourceGroup, vnetName, subnetName)
288-
klog.V(2).Infof("set vnetResourceID(%s) for NFS protocol", vnetResourceID)
289-
vnetResourceIDs = []string{vnetResourceID}
290-
if err := d.updateSubnetServiceEndpoints(ctx, vnetResourceGroup, vnetName, subnetName); err != nil {
291-
return nil, status.Errorf(codes.Internal, "update service endpoints failed with error: %v", err)
290+
subnets := strings.Split(subnetName, ",")
291+
for _, subnet := range subnets {
292+
subnet = strings.TrimSpace(subnet)
293+
vnetResourceID := d.getSubnetResourceID(vnetResourceGroup, vnetName, subnet)
294+
klog.V(2).Infof("set vnetResourceID(%s) for NFS protocol", vnetResourceID)
295+
vnetResourceIDs = []string{vnetResourceID}
296+
if err := d.updateSubnetServiceEndpoints(ctx, vnetResourceGroup, vnetName, subnet); err != nil {
297+
return nil, status.Errorf(codes.Internal, "update service endpoints failed with error: %v", err)
298+
}
292299
}
293300
}
294301
}

pkg/blob/controllerserver_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,30 @@ func TestCreateVolume(t *testing.T) {
407407
}
408408
},
409409
},
410+
{
411+
name: "invalid privateEndpoint and subnetName combination",
412+
testFunc: func(t *testing.T) {
413+
d := NewFakeDriver()
414+
mp := map[string]string{
415+
networkEndpointTypeField: "privateendpoint",
416+
subnetNameField: "subnet1,subnet2",
417+
}
418+
req := &csi.CreateVolumeRequest{
419+
Name: "unit-test",
420+
VolumeCapabilities: stdVolumeCapabilities,
421+
Parameters: mp,
422+
}
423+
d.Cap = []*csi.ControllerServiceCapability{
424+
controllerServiceCapability,
425+
}
426+
427+
expectedErr := status.Errorf(codes.InvalidArgument, "subnetName(subnet1,subnet2) can only contain one subnet for private endpoint")
428+
_, err := d.CreateVolume(context.Background(), req)
429+
if !reflect.DeepEqual(err, expectedErr) {
430+
t.Errorf("Unexpected error: %v", err)
431+
}
432+
},
433+
},
410434
{
411435
name: "NFS not supported by cross subscription",
412436
testFunc: func(t *testing.T) {

0 commit comments

Comments
 (0)