Skip to content

Commit aba979c

Browse files
authored
Merge pull request #658 from andyzhangx/fix-account-creation-issue
fix: disable match tags by default in account search when creating a new volume
2 parents e7367a1 + 1be50c0 commit aba979c

File tree

12 files changed

+70
-19
lines changed

12 files changed

+70
-19
lines changed

docs/driver-parameters.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ containerName | specify the existing container(directory) name | existing contai
1717
containerNamePrefix | specify Azure storage directory prefix created by driver | can only contain lowercase letters, numbers, hyphens, and length should be less than 21 | No |
1818
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
1919
allowBlobPublicAccess | Allow or disallow public access to all blobs or containers for storage account created by driver | `true`,`false` | No | `false`
20-
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`
20+
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
2121
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 | ""
22+
matchTags | whether matching tags when driver tries to find a suitable storage account | `true`,`false` | No | `false`
2223
--- | **Following parameters are only for blobfuse** | --- | --- |
2324
subscriptionID | specify Azure subscription ID in which blob storage directory will be created | Azure subscription ID | No | if not empty, `resourceGroup` must be provided
2425
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`

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module sigs.k8s.io/blob-csi-driver
33
go 1.17
44

55
require (
6-
github.com/Azure/azure-sdk-for-go v63.1.0+incompatible
6+
github.com/Azure/azure-sdk-for-go v63.2.0+incompatible
77
github.com/Azure/go-autorest/autorest v0.11.25
88
github.com/Azure/go-autorest/autorest/adal v0.9.18
99
github.com/Azure/go-autorest/autorest/to v0.4.0
@@ -145,5 +145,5 @@ replace (
145145
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.23.3
146146
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.23.3
147147
k8s.io/sample-controller => k8s.io/sample-controller v0.23.3
148-
sigs.k8s.io/cloud-provider-azure => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220406062855-4f3bab6bc8b2
148+
sigs.k8s.io/cloud-provider-azure => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220415032100-325969906b39
149149
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
4141
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
4242
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
4343
github.com/Azure/azure-sdk-for-go v55.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
44-
github.com/Azure/azure-sdk-for-go v63.1.0+incompatible h1:yNC7qlSUWVF8p0TzxdmWW1FJ3DdIA+0Pge41IU/2+9U=
45-
github.com/Azure/azure-sdk-for-go v63.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
44+
github.com/Azure/azure-sdk-for-go v63.2.0+incompatible h1:OIqkK/zTGqVUuzpEvY0B1YSYDRAFC/j+y0w2GovCggI=
45+
github.com/Azure/azure-sdk-for-go v63.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
4646
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
4747
github.com/Azure/go-ansiterm v0.0.0-20210608223527-2377c96fe795/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
4848
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
@@ -1204,8 +1204,8 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
12041204
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
12051205
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.27 h1:KQOkVzXrLNb0EP6W0FD6u3CCPAwgXFYwZitbj7K0P0Y=
12061206
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.27/go.mod h1:tq2nT0Kx7W+/f2JVE+zxYtUhdjuELJkVpNz+x/QN5R4=
1207-
sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220406062855-4f3bab6bc8b2 h1:d5k/54npFCwuvcAMAqS6ROjQwwNTfCWbHjT2ivQ2vGA=
1208-
sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220406062855-4f3bab6bc8b2/go.mod h1:QP8vTdPEAKK2W+sIgCDQIr15Ivc+tYMRMrJS+Clv85I=
1207+
sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220415032100-325969906b39 h1:R4ccCIcWH35eFgLm/gemTXKG9sfjRFIvHU9RTQ8E19Q=
1208+
sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220415032100-325969906b39/go.mod h1:k/vjhynZDcDyV8Z1Pfpmel/SfoNC6mKHU9K9Nmf85i4=
12091209
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 h1:fD1pz4yfdADVNfFmcP2aBEtudwUQ1AlLnRBALr33v3s=
12101210
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6/go.mod h1:p4QtZmO4uMYipTQNzagwnNoseA6OxSUutVw05NhYDRs=
12111211
sigs.k8s.io/kustomize/api v0.10.1/go.mod h1:2FigT1QN6xKdcnGS2Ppp1uIWrtWN28Ms8A3OZUZhwr8=

pkg/blob/blob.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const (
5252
serverNameField = "server"
5353
storageEndpointSuffixField = "storageendpointsuffix"
5454
tagsField = "tags"
55+
matchTagsField = "matchtags"
5556
protocolField = "protocol"
5657
accountNameField = "accountname"
5758
accountKeyField = "accountkey"

pkg/blob/controllerserver.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
7070
var storageAccountType, subsID, resourceGroup, location, account, containerName, containerNamePrefix, protocol, customTags, secretName, secretNamespace, pvcNamespace string
7171
var isHnsEnabled *bool
7272
var vnetResourceGroup, vnetName, subnetName string
73+
var matchTags bool
7374
// set allowBlobPublicAccess as false by default
7475
allowBlobPublicAccess := to.BoolPtr(false)
7576

@@ -100,6 +101,8 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
100101
protocol = v
101102
case tagsField:
102103
customTags = v
104+
case matchTagsField:
105+
matchTags = strings.EqualFold(v, trueValue)
103106
case secretNameField:
104107
secretName = v
105108
case secretNamespaceField:
@@ -144,6 +147,10 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
144147
}
145148
}
146149

150+
if matchTags && account != "" {
151+
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("matchTags must set as false when storageAccount(%s) is provided", account))
152+
}
153+
147154
if subsID != "" && subsID != d.cloud.SubscriptionID {
148155
if protocol == nfs {
149156
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("NFS protocol is not supported in cross subscription(%s)", subsID))
@@ -225,6 +232,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
225232
EnableHTTPSTrafficOnly: enableHTTPSTrafficOnly,
226233
VirtualNetworkResourceIDs: vnetResourceIDs,
227234
Tags: tags,
235+
MatchTags: matchTags,
228236
IsHnsEnabled: isHnsEnabled,
229237
EnableNfsV3: enableNfsV3,
230238
AllowBlobPublicAccess: allowBlobPublicAccess,

pkg/blob/controllerserver_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,30 @@ func TestCreateVolume(t *testing.T) {
171171
}
172172
},
173173
},
174+
{
175+
name: "storageAccount and matchTags conflict",
176+
testFunc: func(t *testing.T) {
177+
d := NewFakeDriver()
178+
d.cloud = &azure.Cloud{}
179+
mp := map[string]string{
180+
storageAccountField: "abc",
181+
matchTagsField: "true",
182+
}
183+
req := &csi.CreateVolumeRequest{
184+
Name: "unit-test",
185+
VolumeCapabilities: stdVolumeCapabilities,
186+
Parameters: mp,
187+
}
188+
d.Cap = []*csi.ControllerServiceCapability{
189+
controllerServiceCapability,
190+
}
191+
_, err := d.CreateVolume(context.Background(), req)
192+
expectedErr := status.Errorf(codes.InvalidArgument, "matchTags must set as false when storageAccount(abc) is provided")
193+
if !reflect.DeepEqual(err, expectedErr) {
194+
t.Errorf("actualErr: (%v), expectedErr: (%v)", err, expectedErr)
195+
}
196+
},
197+
},
174198
{
175199
name: "containerName and containerNamePrefix could not be specified together",
176200
testFunc: func(t *testing.T) {

test/e2e/dynamic_provisioning_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,12 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() {
426426
},
427427
}
428428
test := testsuites.DynamicallyProvisionedResizeVolumeTest{
429-
CSIDriver: testDriver,
430-
Pods: pods,
431-
StorageClassParameters: map[string]string{"skuName": "Standard_LRS"},
429+
CSIDriver: testDriver,
430+
Pods: pods,
431+
StorageClassParameters: map[string]string{
432+
"skuName": "Standard_LRS",
433+
"matchTags": "true",
434+
},
432435
}
433436
test.Run(cs, ns)
434437
})

vendor/github.com/Azure/azure-sdk-for-go/version/version.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# github.com/Azure/azure-sdk-for-go v63.1.0+incompatible
1+
# github.com/Azure/azure-sdk-for-go v63.2.0+incompatible
22
## explicit
33
github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2021-07-01/compute
44
github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2020-04-01/containerservice
@@ -1082,7 +1082,7 @@ k8s.io/utils/trace
10821082
## explicit; go 1.17
10831083
sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client
10841084
sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/client
1085-
# sigs.k8s.io/cloud-provider-azure v0.7.4 => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220406062855-4f3bab6bc8b2
1085+
# sigs.k8s.io/cloud-provider-azure v0.7.4 => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220415032100-325969906b39
10861086
## explicit; go 1.17
10871087
sigs.k8s.io/cloud-provider-azure/pkg/auth
10881088
sigs.k8s.io/cloud-provider-azure/pkg/azureclients
@@ -1176,4 +1176,4 @@ sigs.k8s.io/yaml
11761176
# k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.23.3
11771177
# k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.23.3
11781178
# k8s.io/sample-controller => k8s.io/sample-controller v0.23.3
1179-
# sigs.k8s.io/cloud-provider-azure => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220406062855-4f3bab6bc8b2
1179+
# sigs.k8s.io/cloud-provider-azure => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220415032100-325969906b39

vendor/sigs.k8s.io/cloud-provider-azure/pkg/consts/consts.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)