Skip to content

Commit ee4b608

Browse files
committed
fix: use new naming rule for nfs container
1 parent b21e87d commit ee4b608

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

docs/driver-parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ location | Azure location | `eastus`, `westus`, etc. | No | if empty, driver wil
1515
resourceGroup | Azure resource group name | existing resource group name | No | if empty, driver will use the same resource group name as current k8s cluster
1616
storageAccount | specify Azure storage account name| STORAGE_ACCOUNT_NAME | - No for blobfuse mount </br> - Yes for NFSv3 mount | - For blobfuse mount: if empty, driver will find a suitable storage account that matches `skuName` in the same resource group; if a storage account name is provided, storage account must exist. </br> - For NFSv3 mount, storage account name must be provided
1717
protocol | specify blobfuse mount or NFSv3 mount | `fuse`, `nfs` | No | `fuse`
18-
containerName | specify the existing container name | existing container name | No | if empty, driver will create a new container name, starting with `pvc-fuse`
18+
containerName | specify the existing container name | existing container name | No | if empty, driver will create a new container name, starting with `pvc-fuse` for blobfuse or `pvc-nfs` for NFSv3
1919
server | specify Azure storage account server address | existing server address, e.g. `accountname.privatelink.blob.core.windows.net` | No | if empty, driver will use default `accountname.blob.core.windows.net` or other sovereign cloud account address
2020
tags | [tags](https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources) would be created in newly created storage account | tag format: 'foo=aaa,bar=bbb' | No | ""
2121

pkg/blob/blobfuse.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ func appendDefaultMountOptions(mountOptions []string) []string {
191191
// 4. Container names must be from 3 through 63 characters long.
192192
//
193193
// See https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata#container-names
194-
func getValidContainerName(volumeName string) string {
194+
func getValidContainerName(volumeName, protocol string) string {
195195
containerName := strings.ToLower(volumeName)
196196
if len(containerName) > containerNameMaxLength {
197197
containerName = containerName[0:containerNameMaxLength]
198198
}
199199
if !checkContainerNameBeginAndEnd(containerName) || len(containerName) < containerNameMinLength {
200200
// now we set as 63 for maximum container name length
201201
// todo: get cluster name
202-
containerName = k8sutil.GenerateVolumeName("pvc-fuse", uuid.NewUUID().String(), 63)
202+
containerName = k8sutil.GenerateVolumeName(fmt.Sprintf("pvc-%s", protocol), uuid.NewUUID().String(), 63)
203203
klog.Warningf("the requested volume name (%q) is invalid, so it is regenerated as (%q)", volumeName, containerName)
204204
}
205205
containerName = strings.Replace(containerName, "--", "-", -1)

pkg/blob/blobfuse_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ func TestIsRetriableError(t *testing.T) {
187187
func TestGetValidContainerName(t *testing.T) {
188188
tests := []struct {
189189
volumeName string
190+
protocol string
190191
expected string
191192
}{
192193
{
@@ -212,7 +213,7 @@ func TestGetValidContainerName(t *testing.T) {
212213
}
213214

214215
for _, test := range tests {
215-
result := getValidContainerName(test.volumeName)
216+
result := getValidContainerName(test.volumeName, "")
216217
if !reflect.DeepEqual(result, test.expected) {
217218
t.Errorf("input: %q, getValidContainerName result: %q, expected: %q", test.volumeName, result, test.expected)
218219
}

pkg/blob/controllerserver.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
8484
resourceGroup = d.cloud.ResourceGroup
8585
}
8686

87+
if protocol == "" {
88+
protocol = fuse
89+
}
8790
if !isSupportedProtocol(protocol) {
8891
return nil, status.Errorf(codes.InvalidArgument, "protocol(%s) is not supported, supported protocol list: %v", protocol, supportedProtocolList)
8992
}
@@ -132,7 +135,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
132135
}
133136

134137
if containerName == "" {
135-
containerName = getValidContainerName(name)
138+
containerName = getValidContainerName(name, protocol)
136139
}
137140

138141
klog.V(2).Infof("begin to create container(%s) on account(%s) type(%s) rg(%s) location(%s) size(%d)", containerName, accountName, storageAccountType, resourceGroup, location, requestGiB)

0 commit comments

Comments
 (0)