Skip to content

Commit c45f306

Browse files
authored
Merge pull request #1382 from k8s-infra-cherrypick-robot/cherry-pick-1381-to-release-1.23
[release-1.23] fix: support storeAccountKey as false in cross subscription scenario
2 parents ed16f30 + 50cf4db commit c45f306

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
@@ -85,6 +85,7 @@ pvc-92a4d7f2-f23b-4904-bad4-2cbfcff6e388
8585
Name | Meaning | Available Value | Mandatory | Default value
8686
--- | --- | --- | --- | ---
8787
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 |
88+
volumeAttributes.subscriptionID | specify Azure subscription ID where blob storage directory is located | Azure subscription ID | No | if not empty, `resourceGroup` must be provided
8889
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
8990
volumeAttributes.storageAccount | existing storage account name | existing storage account name | Yes |
9091
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
@@ -226,15 +226,6 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
226226
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("matchTags must set as false when storageAccount(%s) is provided", account))
227227
}
228228

229-
if subsID != "" && subsID != d.cloud.SubscriptionID {
230-
if isNFSProtocol(protocol) {
231-
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("NFS protocol is not supported in cross subscription(%s)", subsID))
232-
}
233-
if !storeAccountKey {
234-
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("storeAccountKey must set as true in cross subscription(%s)", subsID))
235-
}
236-
}
237-
238229
if resourceGroup == "" {
239230
resourceGroup = d.cloud.ResourceGroup
240231
}

pkg/blob/controllerserver_test.go

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -464,71 +464,6 @@ func TestCreateVolume(t *testing.T) {
464464
}
465465
},
466466
},
467-
{
468-
name: "NFS not supported by cross subscription",
469-
testFunc: func(t *testing.T) {
470-
d := NewFakeDriver()
471-
d.cloud = &azure.Cloud{}
472-
d.cloud.SubscriptionID = "bar"
473-
mp := make(map[string]string)
474-
mp[subscriptionIDField] = "foo"
475-
mp[protocolField] = "nfs"
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("NFS protocol is not supported 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-
},
499-
{
500-
name: "storeAccountKey must be set as true in cross subscription",
501-
testFunc: func(t *testing.T) {
502-
d := NewFakeDriver()
503-
d.cloud = &azure.Cloud{}
504-
d.cloud.SubscriptionID = "bar"
505-
mp := make(map[string]string)
506-
mp[subscriptionIDField] = "foo"
507-
mp[storeAccountKeyField] = falseValue
508-
mp[protocolField] = "unit-test"
509-
mp[skuNameField] = "unit-test"
510-
mp[storageAccountTypeField] = "unit-test"
511-
mp[locationField] = "unit-test"
512-
mp[storageAccountField] = "unit-test"
513-
mp[resourceGroupField] = "unit-test"
514-
mp[containerNameField] = "unit-test"
515-
mp[mountPermissionsField] = "0750"
516-
req := &csi.CreateVolumeRequest{
517-
Name: "unit-test",
518-
VolumeCapabilities: stdVolumeCapabilities,
519-
Parameters: mp,
520-
}
521-
d.Cap = []*csi.ControllerServiceCapability{
522-
controllerServiceCapability,
523-
}
524-
525-
expectedErr := status.Errorf(codes.InvalidArgument, fmt.Sprintf("storeAccountKey must set as true in cross subscription(%s)", "foo"))
526-
_, err := d.CreateVolume(context.Background(), req)
527-
if !reflect.DeepEqual(err, expectedErr) {
528-
t.Errorf("Unexpected error: %v", err)
529-
}
530-
},
531-
},
532467
{
533468
name: "Update service endpoints failed (protocol = nfs)",
534469
testFunc: func(t *testing.T) {

0 commit comments

Comments
 (0)