Skip to content

Commit 6f1968e

Browse files
authored
Merge pull request #729 from cvvz/blobclient
feat: support cross subscription with management API
2 parents 00787dd + 873d0c5 commit 6f1968e

File tree

125 files changed

+5909
-415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+5909
-415
lines changed

docs/driver-parameters.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tags | [tags](https://docs.microsoft.com/en-us/azure/azure-resource-manager/mana
2222
matchTags | whether matching tags when driver tries to find a suitable storage account | `true`,`false` | No | `false`
2323
useDataPlaneAPI | specify whether use data plane API for blob container create/delete, this could solve the SRP API throltting issue since data plane API has almost no limit, while it would fail when there is firewall or vnet setting on storage account | `true`,`false` | No | `false`
2424
--- | **Following parameters are only for blobfuse** | --- | --- |
25-
subscriptionID | specify Azure subscription ID in which blob storage directory will be created, cross subscription is only supported when `useDataPlaneAPI` is set as `true` | Azure subscription ID | No | if not empty, `resourceGroup` must be provided
25+
subscriptionID | specify Azure subscription ID in which blob storage directory will be created | Azure subscription ID | No | if not empty, `resourceGroup` must be provided
2626
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`
2727
secretName | specify secret name to store account key | | No |
2828
secretNamespace | specify the namespace of secret to store account key | `default`,`kube-system`, etc | No | pvc namespace
@@ -51,6 +51,8 @@ k8s-azure-created-by: azure
5151
pvc-92a4d7f2-f23b-4904-bad4-2cbfcff6e388
5252
```
5353

54+
- VolumeId is identifier for the volume generated after volume is created by plugin successfully, the format of VolumeId is: `rg#accountName#containerName#uuid#secretNamespace#subsID`, and if current account is in the same subs as the driver, `subsID` would be empty.
55+
5456
### Static Provisioning(bring your own storage container)
5557
> [blobfuse example](../deploy/example/pv-blobfuse-csi.yaml)
5658

go.mod

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ go 1.18
55
require (
66
github.com/Azure/azure-sdk-for-go v65.0.0+incompatible
77
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0
8-
github.com/Azure/go-autorest/autorest v0.11.27
9-
github.com/Azure/go-autorest/autorest/adal v0.9.20
8+
github.com/Azure/go-autorest/autorest v0.11.28
9+
github.com/Azure/go-autorest/autorest/adal v0.9.21
1010
github.com/Azure/go-autorest/autorest/to v0.4.0
1111
github.com/container-storage-interface/spec v1.5.0
1212
github.com/gofrs/uuid v4.2.0+incompatible // indirect
@@ -15,13 +15,13 @@ require (
1515
github.com/imdario/mergo v0.3.9 // indirect
1616
github.com/kubernetes-csi/csi-lib-utils v0.9.1
1717
github.com/onsi/ginkgo v1.16.5
18-
github.com/onsi/gomega v1.19.0
18+
github.com/onsi/gomega v1.20.0
1919
github.com/pborman/uuid v1.2.0
2020
github.com/pelletier/go-toml v1.9.4
2121
github.com/stretchr/testify v1.8.0
2222
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4
2323
google.golang.org/grpc v1.42.0
24-
google.golang.org/protobuf v1.27.1
24+
google.golang.org/protobuf v1.28.0
2525
k8s.io/api v0.24.3
2626
k8s.io/apimachinery v0.24.3
2727
k8s.io/client-go v0.24.3
@@ -30,7 +30,7 @@ require (
3030
k8s.io/kubernetes v1.23.3
3131
k8s.io/mount-utils v0.23.3
3232
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
33-
sigs.k8s.io/cloud-provider-azure v0.7.4
33+
sigs.k8s.io/cloud-provider-azure v1.24.1-0.20220810033612-3e07f125e561
3434
sigs.k8s.io/yaml v1.3.0
3535
)
3636

@@ -66,7 +66,7 @@ require (
6666
github.com/golang-jwt/jwt v3.2.1+incompatible // indirect
6767
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
6868
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
69-
github.com/google/go-cmp v0.5.6 // indirect
69+
github.com/google/go-cmp v0.5.8 // indirect
7070
github.com/google/gofuzz v1.1.0 // indirect
7171
github.com/google/uuid v1.1.2 // indirect
7272
github.com/googleapis/gnostic v0.5.5 // indirect
@@ -102,9 +102,9 @@ require (
102102
go.opentelemetry.io/otel/sdk/metric v0.20.0 // indirect
103103
go.opentelemetry.io/otel/trace v0.20.0 // indirect
104104
go.opentelemetry.io/proto/otlp v0.7.0 // indirect
105-
golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect
105+
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
106106
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
107-
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
107+
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
108108
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
109109
golang.org/x/text v0.3.7 // indirect
110110
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
@@ -114,11 +114,11 @@ require (
114114
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
115115
gopkg.in/yaml.v2 v2.4.0 // indirect
116116
gopkg.in/yaml.v3 v3.0.1 // indirect
117-
k8s.io/cloud-provider v0.24.2 // indirect
117+
k8s.io/cloud-provider v0.24.3 // indirect
118118
k8s.io/component-helpers v0.24.3 // indirect
119119
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
120120
k8s.io/kubectl v0.0.0 // indirect
121-
k8s.io/kubelet v0.24.2 // indirect
121+
k8s.io/kubelet v0.24.3 // indirect
122122
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30 // indirect
123123
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
124124
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
@@ -157,5 +157,5 @@ replace (
157157
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.23.3
158158
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.23.3
159159
k8s.io/sample-controller => k8s.io/sample-controller v0.23.3
160-
sigs.k8s.io/cloud-provider-azure => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220721071156-49e3ba00fb91
160+
sigs.k8s.io/cloud-provider-azure => sigs.k8s.io/cloud-provider-azure v1.24.1-0.20220810033612-3e07f125e561
161161
)

go.sum

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg6
6161
github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs=
6262
github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
6363
github.com/Azure/go-autorest/autorest v0.11.18/go.mod h1:dSiJPy22c3u0OtOKDNttNgqpNFY/GeWa7GH/Pz56QRA=
64-
github.com/Azure/go-autorest/autorest v0.11.27 h1:F3R3q42aWytozkV8ihzcgMO4OA4cuqr3bNlsEuF6//A=
65-
github.com/Azure/go-autorest/autorest v0.11.27/go.mod h1:7l8ybrIdUmGqZMTD0sRtAr8NvbHjfofbf8RSP2q7w7U=
64+
github.com/Azure/go-autorest/autorest v0.11.28 h1:ndAExarwr5Y+GaHE6VCaY1kyS/HwwGGyuimVhWsHOEM=
65+
github.com/Azure/go-autorest/autorest v0.11.28/go.mod h1:MrkzG3Y3AH668QyF9KRk5neJnGgmhQ6krbhR8Q5eMvA=
6666
github.com/Azure/go-autorest/autorest/adal v0.9.13/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M=
6767
github.com/Azure/go-autorest/autorest/adal v0.9.18/go.mod h1:XVVeme+LZwABT8K5Lc3hA4nAe8LDBVle26gTrguhhPQ=
68-
github.com/Azure/go-autorest/autorest/adal v0.9.20 h1:gJ3E98kMpFB1MFqQCvA1yFab8vthOeD4VlFRQULxahg=
69-
github.com/Azure/go-autorest/autorest/adal v0.9.20/go.mod h1:XVVeme+LZwABT8K5Lc3hA4nAe8LDBVle26gTrguhhPQ=
68+
github.com/Azure/go-autorest/autorest/adal v0.9.21 h1:jjQnVFXPfekaqb8vIsv2G1lxshoW+oGv4MDlhRtnYZk=
69+
github.com/Azure/go-autorest/autorest/adal v0.9.21/go.mod h1:zua7mBUaCc5YnSLKYgGJR/w5ePdMDA6H56upLsHzA9U=
7070
github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw=
7171
github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74=
7272
github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k=
@@ -330,8 +330,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
330330
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
331331
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
332332
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
333-
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
334-
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
333+
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
334+
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
335335
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
336336
github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g=
337337
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
@@ -516,8 +516,8 @@ github.com/onsi/ginkgo/v2 v2.1.4 h1:GNapqRSid3zijZ9H77KrgVG4/8KqiyRsxcSxe+7ApXY=
516516
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
517517
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
518518
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
519-
github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw=
520-
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
519+
github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q=
520+
github.com/onsi/gomega v1.20.0/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo=
521521
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
522522
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
523523
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
@@ -705,9 +705,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
705705
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
706706
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
707707
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
708-
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
709-
golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw=
710-
golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
708+
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
709+
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
711710
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
712711
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
713712
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@@ -908,8 +907,9 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
908907
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
909908
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
910909
golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
911-
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0=
912910
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
911+
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc=
912+
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
913913
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
914914
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
915915
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
@@ -992,7 +992,6 @@ golang.org/x/tools v0.1.6-0.20210820212750-d4cc65f0b2ff/go.mod h1:YD9qOF0M9xpSpd
992992
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
993993
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
994994
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
995-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
996995
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
997996
gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
998997
gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0=
@@ -1118,8 +1117,9 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
11181117
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
11191118
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
11201119
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
1121-
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
11221120
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
1121+
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
1122+
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
11231123
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
11241124
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
11251125
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -1227,8 +1227,8 @@ rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
12271227
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.27/go.mod h1:tq2nT0Kx7W+/f2JVE+zxYtUhdjuELJkVpNz+x/QN5R4=
12281228
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30 h1:dUk62HQ3ZFhD48Qr8MIXCiKA8wInBQCtuE4QGfFW7yA=
12291229
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30/go.mod h1:fEO7lRTdivWO2qYVCVG7dEADOMo/MLDCVr8So2g88Uw=
1230-
sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220721071156-49e3ba00fb91 h1:i2AjmSKmRY4KvU/PFo1UcmDHr+KtP58e+O1tg/2yIak=
1231-
sigs.k8s.io/cloud-provider-azure v0.7.4-0.20220721071156-49e3ba00fb91/go.mod h1:VtfgpOsu4dCqrg77K3LuiiVCAfH7M5w/J5Bv7XOBRf0=
1230+
sigs.k8s.io/cloud-provider-azure v1.24.1-0.20220810033612-3e07f125e561 h1:STGz1EqxvY7vskck4iudgfCBuDrA+VjETRGyrtLKTWs=
1231+
sigs.k8s.io/cloud-provider-azure v1.24.1-0.20220810033612-3e07f125e561/go.mod h1:KRSedLdzH6Y6wuqQRf3UdRj5hHv9NtTNxsokyuVE87w=
12321232
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6/go.mod h1:p4QtZmO4uMYipTQNzagwnNoseA6OxSUutVw05NhYDRs=
12331233
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 h1:kDi4JBNAsJWfz1aEXhO8Jg87JJaPNLh5tIzYHgStQ9Y=
12341234
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2/go.mod h1:B+TnT182UBxE84DiCz4CVE26eOSDAeYCpfDnC2kdKMY=

pkg/blob/blob.go

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const (
4949
DefaultDriverName = "blob.csi.azure.com"
5050
blobCSIDriverName = "blob_csi_driver"
5151
separator = "#"
52-
volumeIDTemplate = "%s#%s#%s#%s#%s"
52+
volumeIDTemplate = "%s#%s#%s#%s#%s#%s"
5353
secretNameTemplate = "azure-storage-account-%s-secret"
5454
serverNameField = "server"
5555
storageEndpointSuffixField = "storageendpointsuffix"
@@ -265,21 +265,29 @@ func (d *Driver) Run(endpoint, kubeconfig string, testBool bool) {
265265
s.Wait()
266266
}
267267

268-
// GetContainerInfo get container info according to volume id, e.g.
269-
// input: "rg#f5713de20cde511e8ba4900#containerName#uuid"
270-
// output: rg, f5713de20cde511e8ba4900, containerName
271-
// input: "rg#f5713de20cde511e8ba4900#containerName#uuid#namespace"
272-
// output: rg, f5713de20cde511e8ba4900, containerName, namespace
273-
func GetContainerInfo(id string) (string, string, string, string, error) {
268+
// GetContainerInfo get container info according to volume id
269+
// the format of VolumeId is: rg#accountName#containerName#uuid#secretNamespace#subsID
270+
//
271+
// e.g.
272+
// input: "rg#f5713de20cde511e8ba4900#containerName#uuid#"
273+
// output: rg, f5713de20cde511e8ba4900, containerName, "" , ""
274+
// input: "rg#f5713de20cde511e8ba4900#containerName#uuid#namespace#"
275+
// output: rg, f5713de20cde511e8ba4900, containerName, namespace, ""
276+
// input: "rg#f5713de20cde511e8ba4900#containerName#uuid#namespace#subsID"
277+
// output: rg, f5713de20cde511e8ba4900, containerName, namespace, subsID
278+
func GetContainerInfo(id string) (string, string, string, string, string, error) {
274279
segments := strings.Split(id, separator)
275280
if len(segments) < 3 {
276-
return "", "", "", "", fmt.Errorf("error parsing volume id: %q, should at least contain two #", id)
281+
return "", "", "", "", "", fmt.Errorf("error parsing volume id: %q, should at least contain two #", id)
277282
}
278-
var secretNamespace string
283+
var secretNamespace, subsID string
279284
if len(segments) > 4 {
280285
secretNamespace = segments[4]
281286
}
282-
return segments[0], segments[1], segments[2], secretNamespace, nil
287+
if len(segments) > 5 {
288+
subsID = segments[5]
289+
}
290+
return segments[0], segments[1], segments[2], secretNamespace, subsID, nil
283291
}
284292

285293
// A container name must be a valid DNS name, conforming to the following naming rules:
@@ -323,7 +331,7 @@ func isSASToken(key string) bool {
323331

324332
// GetAuthEnv return <accountName, containerName, authEnv, error>
325333
func (d *Driver) GetAuthEnv(ctx context.Context, volumeID, protocol string, attrib, secrets map[string]string) (string, string, string, string, []string, error) {
326-
rgName, accountName, containerName, secretNamespace, err := GetContainerInfo(volumeID)
334+
rgName, accountName, containerName, secretNamespace, _, err := GetContainerInfo(volumeID)
327335
if err != nil {
328336
// ignore volumeID parsing error
329337
klog.V(2).Infof("parsing volumeID(%s) return with error: %v", volumeID, err)
@@ -530,7 +538,7 @@ func (d *Driver) GetStorageAccountAndContainer(ctx context.Context, volumeID str
530538
} else {
531539
if len(secrets) == 0 {
532540
var rgName string
533-
rgName, accountName, containerName, _, err = GetContainerInfo(volumeID)
541+
rgName, accountName, containerName, _, _, err = GetContainerInfo(volumeID)
534542
if err != nil {
535543
return "", "", "", "", err
536544
}

pkg/blob/blob_test.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"strings"
2828
"testing"
2929

30-
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2021-02-01/storage"
30+
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2021-09-01/storage"
3131
"github.com/golang/mock/gomock"
3232
"github.com/stretchr/testify/assert"
3333

@@ -173,6 +173,7 @@ func TestGetContainerInfo(t *testing.T) {
173173
account string
174174
container string
175175
namespace string
176+
subsID string
176177
expectedError error
177178
}{
178179
{
@@ -241,13 +242,38 @@ func TestGetContainerInfo(t *testing.T) {
241242
container: "",
242243
expectedError: fmt.Errorf("error parsing volume id: \"\", should at least contain two #"),
243244
},
245+
{
246+
volumeID: "rg#f5713de20cde511e8ba4900#container#uuid#namespace#subsID",
247+
rg: "rg",
248+
account: "f5713de20cde511e8ba4900",
249+
container: "container",
250+
namespace: "namespace",
251+
subsID: "subsID",
252+
expectedError: nil,
253+
},
254+
{
255+
volumeID: "rg#f5713de20cde511e8ba4900#container###subsID",
256+
rg: "rg",
257+
account: "f5713de20cde511e8ba4900",
258+
container: "container",
259+
subsID: "subsID",
260+
expectedError: nil,
261+
},
262+
{
263+
volumeID: "rg#f5713de20cde511e8ba4900#container#uuid#namespace#",
264+
rg: "rg",
265+
account: "f5713de20cde511e8ba4900",
266+
container: "container",
267+
namespace: "namespace",
268+
expectedError: nil,
269+
},
244270
}
245271

246272
for _, test := range tests {
247-
rg, account, container, ns, err := GetContainerInfo(test.volumeID)
273+
rg, account, container, ns, subsID, err := GetContainerInfo(test.volumeID)
248274
if !reflect.DeepEqual(rg, test.rg) || !reflect.DeepEqual(account, test.account) ||
249275
!reflect.DeepEqual(container, test.container) || !reflect.DeepEqual(err, test.expectedError) ||
250-
!reflect.DeepEqual(ns, test.namespace) {
276+
!reflect.DeepEqual(ns, test.namespace) || !reflect.DeepEqual(subsID, test.subsID) {
251277
t.Errorf("input: %q, GetContainerInfo rg: %q, rg: %q, account: %q, account: %q, container: %q, container: %q, namespace: %q, namespace: %q, err: %q, expectedError: %q", test.volumeID, rg, test.rg, account, test.account,
252278
container, test.container, ns, test.namespace, err, test.expectedError)
253279
}

0 commit comments

Comments
 (0)