Skip to content

Commit

Permalink
Merge pull request #658 from andyzhangx/fix-account-creation-issue
Browse files Browse the repository at this point in the history
fix: disable match tags by default in account search when creating a new volume
  • Loading branch information
andyzhangx authored Apr 15, 2022
2 parents e7367a1 + 1be50c0 commit aba979c
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 19 deletions.
3 changes: 2 additions & 1 deletion docs/driver-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ containerName | specify the existing container(directory) name | existing contai
containerNamePrefix | specify Azure storage directory prefix created by driver | can only contain lowercase letters, numbers, hyphens, and length should be less than 21 | No |
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
allowBlobPublicAccess | Allow or disallow public access to all blobs or containers for storage account created by driver | `true`,`false` | No | `false`
storageEndpointSuffix | specify Azure storage endpoint suffix | `core.windows.net` | No | if empty, driver will use default storage endpoint suffix according to cloud environment, e.g. `core.windows.net`
storageEndpointSuffix | specify Azure storage endpoint suffix | `core.windows.net`, `core.chinacloudapi.cn`, etc | No | if empty, driver will use default storage endpoint suffix according to cloud environment
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 | ""
matchTags | whether matching tags when driver tries to find a suitable storage account | `true`,`false` | No | `false`
--- | **Following parameters are only for blobfuse** | --- | --- |
subscriptionID | specify Azure subscription ID in which blob storage directory will be created | Azure subscription ID | No | if not empty, `resourceGroup` must be provided
storeAccountKey | whether store account key to k8s secret <br><br> Note: <br> `false` means driver would leverage kubelet identity to get account key | `true`,`false` | No | `true`
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module sigs.k8s.io/blob-csi-driver
go 1.17

require (
github.com/Azure/azure-sdk-for-go v63.1.0+incompatible
github.com/Azure/azure-sdk-for-go v63.2.0+incompatible
github.com/Azure/go-autorest/autorest v0.11.25
github.com/Azure/go-autorest/autorest/adal v0.9.18
github.com/Azure/go-autorest/autorest/to v0.4.0
Expand Down Expand Up @@ -145,5 +145,5 @@ replace (
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.23.3
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.23.3
k8s.io/sample-controller => k8s.io/sample-controller v0.23.3
sigs.k8s.io/cloud-provider-azure => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220406062855-4f3bab6bc8b2
sigs.k8s.io/cloud-provider-azure => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220415032100-325969906b39
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/Azure/azure-sdk-for-go v55.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go v63.1.0+incompatible h1:yNC7qlSUWVF8p0TzxdmWW1FJ3DdIA+0Pge41IU/2+9U=
github.com/Azure/azure-sdk-for-go v63.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go v63.2.0+incompatible h1:OIqkK/zTGqVUuzpEvY0B1YSYDRAFC/j+y0w2GovCggI=
github.com/Azure/azure-sdk-for-go v63.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
github.com/Azure/go-ansiterm v0.0.0-20210608223527-2377c96fe795/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
Expand Down Expand Up @@ -1204,8 +1204,8 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.27 h1:KQOkVzXrLNb0EP6W0FD6u3CCPAwgXFYwZitbj7K0P0Y=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.27/go.mod h1:tq2nT0Kx7W+/f2JVE+zxYtUhdjuELJkVpNz+x/QN5R4=
sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220406062855-4f3bab6bc8b2 h1:d5k/54npFCwuvcAMAqS6ROjQwwNTfCWbHjT2ivQ2vGA=
sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220406062855-4f3bab6bc8b2/go.mod h1:QP8vTdPEAKK2W+sIgCDQIr15Ivc+tYMRMrJS+Clv85I=
sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220415032100-325969906b39 h1:R4ccCIcWH35eFgLm/gemTXKG9sfjRFIvHU9RTQ8E19Q=
sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220415032100-325969906b39/go.mod h1:k/vjhynZDcDyV8Z1Pfpmel/SfoNC6mKHU9K9Nmf85i4=
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 h1:fD1pz4yfdADVNfFmcP2aBEtudwUQ1AlLnRBALr33v3s=
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6/go.mod h1:p4QtZmO4uMYipTQNzagwnNoseA6OxSUutVw05NhYDRs=
sigs.k8s.io/kustomize/api v0.10.1/go.mod h1:2FigT1QN6xKdcnGS2Ppp1uIWrtWN28Ms8A3OZUZhwr8=
Expand Down
1 change: 1 addition & 0 deletions pkg/blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const (
serverNameField = "server"
storageEndpointSuffixField = "storageendpointsuffix"
tagsField = "tags"
matchTagsField = "matchtags"
protocolField = "protocol"
accountNameField = "accountname"
accountKeyField = "accountkey"
Expand Down
8 changes: 8 additions & 0 deletions pkg/blob/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
var storageAccountType, subsID, resourceGroup, location, account, containerName, containerNamePrefix, protocol, customTags, secretName, secretNamespace, pvcNamespace string
var isHnsEnabled *bool
var vnetResourceGroup, vnetName, subnetName string
var matchTags bool
// set allowBlobPublicAccess as false by default
allowBlobPublicAccess := to.BoolPtr(false)

Expand Down Expand Up @@ -100,6 +101,8 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
protocol = v
case tagsField:
customTags = v
case matchTagsField:
matchTags = strings.EqualFold(v, trueValue)
case secretNameField:
secretName = v
case secretNamespaceField:
Expand Down Expand Up @@ -144,6 +147,10 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
}
}

if matchTags && account != "" {
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 protocol == nfs {
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("NFS protocol is not supported in cross subscription(%s)", subsID))
Expand Down Expand Up @@ -225,6 +232,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
EnableHTTPSTrafficOnly: enableHTTPSTrafficOnly,
VirtualNetworkResourceIDs: vnetResourceIDs,
Tags: tags,
MatchTags: matchTags,
IsHnsEnabled: isHnsEnabled,
EnableNfsV3: enableNfsV3,
AllowBlobPublicAccess: allowBlobPublicAccess,
Expand Down
24 changes: 24 additions & 0 deletions pkg/blob/controllerserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,30 @@ func TestCreateVolume(t *testing.T) {
}
},
},
{
name: "storageAccount and matchTags conflict",
testFunc: func(t *testing.T) {
d := NewFakeDriver()
d.cloud = &azure.Cloud{}
mp := map[string]string{
storageAccountField: "abc",
matchTagsField: "true",
}
req := &csi.CreateVolumeRequest{
Name: "unit-test",
VolumeCapabilities: stdVolumeCapabilities,
Parameters: mp,
}
d.Cap = []*csi.ControllerServiceCapability{
controllerServiceCapability,
}
_, err := d.CreateVolume(context.Background(), req)
expectedErr := status.Errorf(codes.InvalidArgument, "matchTags must set as false when storageAccount(abc) is provided")
if !reflect.DeepEqual(err, expectedErr) {
t.Errorf("actualErr: (%v), expectedErr: (%v)", err, expectedErr)
}
},
},
{
name: "containerName and containerNamePrefix could not be specified together",
testFunc: func(t *testing.T) {
Expand Down
9 changes: 6 additions & 3 deletions test/e2e/dynamic_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,12 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() {
},
}
test := testsuites.DynamicallyProvisionedResizeVolumeTest{
CSIDriver: testDriver,
Pods: pods,
StorageClassParameters: map[string]string{"skuName": "Standard_LRS"},
CSIDriver: testDriver,
Pods: pods,
StorageClassParameters: map[string]string{
"skuName": "Standard_LRS",
"matchTags": "true",
},
}
test.Run(cs, ns)
})
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# github.com/Azure/azure-sdk-for-go v63.1.0+incompatible
# github.com/Azure/azure-sdk-for-go v63.2.0+incompatible
## explicit
github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2021-07-01/compute
github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2020-04-01/containerservice
Expand Down Expand Up @@ -1082,7 +1082,7 @@ k8s.io/utils/trace
## explicit; go 1.17
sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client
sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/client
# sigs.k8s.io/cloud-provider-azure v0.7.4 => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220406062855-4f3bab6bc8b2
# sigs.k8s.io/cloud-provider-azure v0.7.4 => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220415032100-325969906b39
## explicit; go 1.17
sigs.k8s.io/cloud-provider-azure/pkg/auth
sigs.k8s.io/cloud-provider-azure/pkg/azureclients
Expand Down Expand Up @@ -1176,4 +1176,4 @@ sigs.k8s.io/yaml
# k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.23.3
# k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.23.3
# k8s.io/sample-controller => k8s.io/sample-controller v0.23.3
# sigs.k8s.io/cloud-provider-azure => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220406062855-4f3bab6bc8b2
# sigs.k8s.io/cloud-provider-azure => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220415032100-325969906b39

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit aba979c

Please sign in to comment.