Skip to content

[release-1.24] fix: support storeAccountKey as false in cross subscription scenario #1383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/driver-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pvc-92a4d7f2-f23b-4904-bad4-2cbfcff6e388
Name | Meaning | Available Value | Mandatory | Default value
--- | --- | --- | --- | ---
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 |
volumeAttributes.subscriptionID | specify Azure subscription ID where blob storage directory is located | Azure subscription ID | No | if not empty, `resourceGroup` must be provided
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
volumeAttributes.storageAccount | existing storage account name | existing storage account name | Yes |
volumeAttributes.containerName | existing container name | existing container name | Yes |
Expand Down
9 changes: 0 additions & 9 deletions pkg/blob/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,6 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("matchTags must set as false when storageAccount(%s) is provided", account))
}

if subsID != "" && subsID != d.cloud.SubscriptionID {
if isNFSProtocol(protocol) {
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("NFS protocol is not supported in cross subscription(%s)", subsID))
}
if !storeAccountKey {
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("storeAccountKey must set as true in cross subscription(%s)", subsID))
}
}

if resourceGroup == "" {
resourceGroup = d.cloud.ResourceGroup
}
Expand Down
65 changes: 0 additions & 65 deletions pkg/blob/controllerserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,71 +431,6 @@ func TestCreateVolume(t *testing.T) {
}
},
},
{
name: "NFS not supported by cross subscription",
testFunc: func(t *testing.T) {
d := NewFakeDriver()
d.cloud = &azure.Cloud{}
d.cloud.SubscriptionID = "bar"
mp := make(map[string]string)
mp[subscriptionIDField] = "foo"
mp[protocolField] = "nfs"
mp[skuNameField] = "unit-test"
mp[storageAccountTypeField] = "unit-test"
mp[locationField] = "unit-test"
mp[storageAccountField] = "unit-test"
mp[resourceGroupField] = "unit-test"
mp[containerNameField] = "unit-test"
mp[mountPermissionsField] = "0750"
req := &csi.CreateVolumeRequest{
Name: "unit-test",
VolumeCapabilities: stdVolumeCapabilities,
Parameters: mp,
}
d.Cap = []*csi.ControllerServiceCapability{
controllerServiceCapability,
}

expectedErr := status.Errorf(codes.InvalidArgument, fmt.Sprintf("NFS protocol is not supported in cross subscription(%s)", "foo"))
_, err := d.CreateVolume(context.Background(), req)
if !reflect.DeepEqual(err, expectedErr) {
t.Errorf("Unexpected error: %v", err)
}
},
},
{
name: "storeAccountKey must be set as true in cross subscription",
testFunc: func(t *testing.T) {
d := NewFakeDriver()
d.cloud = &azure.Cloud{}
d.cloud.SubscriptionID = "bar"
mp := make(map[string]string)
mp[subscriptionIDField] = "foo"
mp[storeAccountKeyField] = falseValue
mp[protocolField] = "unit-test"
mp[skuNameField] = "unit-test"
mp[storageAccountTypeField] = "unit-test"
mp[locationField] = "unit-test"
mp[storageAccountField] = "unit-test"
mp[resourceGroupField] = "unit-test"
mp[containerNameField] = "unit-test"
mp[mountPermissionsField] = "0750"
req := &csi.CreateVolumeRequest{
Name: "unit-test",
VolumeCapabilities: stdVolumeCapabilities,
Parameters: mp,
}
d.Cap = []*csi.ControllerServiceCapability{
controllerServiceCapability,
}

expectedErr := status.Errorf(codes.InvalidArgument, fmt.Sprintf("storeAccountKey must set as true in cross subscription(%s)", "foo"))
_, err := d.CreateVolume(context.Background(), req)
if !reflect.DeepEqual(err, expectedErr) {
t.Errorf("Unexpected error: %v", err)
}
},
},
{
name: "Update service endpoints failed (protocol = nfs)",
testFunc: func(t *testing.T) {
Expand Down
Loading