Skip to content

Commit 0803552

Browse files
committed
fix: support storeAccountKey as true in cross subscription scenario
fix
1 parent 6484524 commit 0803552

File tree

3 files changed

+1
-74
lines changed

3 files changed

+1
-74
lines changed

docs/driver-parameters.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ pvc-92a4d7f2-f23b-4904-bad4-2cbfcff6e388
9898
Name | Meaning | Available Value | Mandatory | Default value
9999
--- | --- | --- | --- | ---
100100
volumeHandle | Specify a value the driver can use to uniquely identify the storage blob container in the cluster. | A recommended way to produce a unique value is to combine the globally unique storage account name and container name: {account-name}_{container-name}. Note: the # character is reserved for internal use, the / character is not allowed. | Yes |
101+
volumeAttributes.subscriptionID | specify Azure subscription ID where blob storage directory is located | Azure subscription ID | No | if not empty, `resourceGroup` must be provided
101102
volumeAttributes.resourceGroup | Azure resource group name | existing resource group name | No | if empty, driver will use the same resource group name as current k8s cluster
102103
volumeAttributes.storageAccount | existing storage account name | existing storage account name | Yes |
103104
volumeAttributes.containerName | existing container name | existing container name | Yes |

pkg/blob/controllerserver.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,6 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
232232
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("matchTags must set as false when storageAccount(%s) is provided", account))
233233
}
234234

235-
if subsID != "" && subsID != d.cloud.SubscriptionID {
236-
if isNFSProtocol(protocol) {
237-
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("NFS protocol is not supported in cross subscription(%s)", subsID))
238-
}
239-
if !storeAccountKey {
240-
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("storeAccountKey must set as true in cross subscription(%s)", subsID))
241-
}
242-
}
243-
244235
if resourceGroup == "" {
245236
resourceGroup = d.cloud.ResourceGroup
246237
}

pkg/blob/controllerserver_test.go

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -431,71 +431,6 @@ func TestCreateVolume(t *testing.T) {
431431
}
432432
},
433433
},
434-
{
435-
name: "NFS not supported by cross subscription",
436-
testFunc: func(t *testing.T) {
437-
d := NewFakeDriver()
438-
d.cloud = &azure.Cloud{}
439-
d.cloud.SubscriptionID = "bar"
440-
mp := make(map[string]string)
441-
mp[subscriptionIDField] = "foo"
442-
mp[protocolField] = "nfs"
443-
mp[skuNameField] = "unit-test"
444-
mp[storageAccountTypeField] = "unit-test"
445-
mp[locationField] = "unit-test"
446-
mp[storageAccountField] = "unit-test"
447-
mp[resourceGroupField] = "unit-test"
448-
mp[containerNameField] = "unit-test"
449-
mp[mountPermissionsField] = "0750"
450-
req := &csi.CreateVolumeRequest{
451-
Name: "unit-test",
452-
VolumeCapabilities: stdVolumeCapabilities,
453-
Parameters: mp,
454-
}
455-
d.Cap = []*csi.ControllerServiceCapability{
456-
controllerServiceCapability,
457-
}
458-
459-
expectedErr := status.Errorf(codes.InvalidArgument, fmt.Sprintf("NFS protocol is not supported in cross subscription(%s)", "foo"))
460-
_, err := d.CreateVolume(context.Background(), req)
461-
if !reflect.DeepEqual(err, expectedErr) {
462-
t.Errorf("Unexpected error: %v", err)
463-
}
464-
},
465-
},
466-
{
467-
name: "storeAccountKey must be set as true in cross subscription",
468-
testFunc: func(t *testing.T) {
469-
d := NewFakeDriver()
470-
d.cloud = &azure.Cloud{}
471-
d.cloud.SubscriptionID = "bar"
472-
mp := make(map[string]string)
473-
mp[subscriptionIDField] = "foo"
474-
mp[storeAccountKeyField] = falseValue
475-
mp[protocolField] = "unit-test"
476-
mp[skuNameField] = "unit-test"
477-
mp[storageAccountTypeField] = "unit-test"
478-
mp[locationField] = "unit-test"
479-
mp[storageAccountField] = "unit-test"
480-
mp[resourceGroupField] = "unit-test"
481-
mp[containerNameField] = "unit-test"
482-
mp[mountPermissionsField] = "0750"
483-
req := &csi.CreateVolumeRequest{
484-
Name: "unit-test",
485-
VolumeCapabilities: stdVolumeCapabilities,
486-
Parameters: mp,
487-
}
488-
d.Cap = []*csi.ControllerServiceCapability{
489-
controllerServiceCapability,
490-
}
491-
492-
expectedErr := status.Errorf(codes.InvalidArgument, fmt.Sprintf("storeAccountKey must set as true in cross subscription(%s)", "foo"))
493-
_, err := d.CreateVolume(context.Background(), req)
494-
if !reflect.DeepEqual(err, expectedErr) {
495-
t.Errorf("Unexpected error: %v", err)
496-
}
497-
},
498-
},
499434
{
500435
name: "Update service endpoints failed (protocol = nfs)",
501436
testFunc: func(t *testing.T) {

0 commit comments

Comments
 (0)