Skip to content

Commit 504e867

Browse files
authored
Merge pull request #186 from andyzhangx/upgrade-provider
chore: upgrade azure cloud provider
2 parents 79b752a + fe15307 commit 504e867

Some content is hidden

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

61 files changed

+1180
-1520
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
k8s.io/klog/v2 v2.2.0
2424
k8s.io/kubernetes v1.18.5
2525
k8s.io/legacy-cloud-providers v0.0.0
26-
k8s.io/utils v0.0.0-20200619165400-6e3d28b6ed19
26+
k8s.io/utils v0.0.0-20200729134348-d5654de09c73
2727
sigs.k8s.io/yaml v1.2.0
2828
)
2929

@@ -50,7 +50,7 @@ replace (
5050
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.18.1
5151
k8s.io/kubectl => k8s.io/kubectl v0.18.1
5252
k8s.io/kubelet => k8s.io/kubelet v0.18.1
53-
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.0.0-20200711020551-224d5470706b
53+
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.0.0-20200731174458-cce61a865d46
5454
k8s.io/metrics => k8s.io/metrics v0.18.1
5555
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.18.1
5656
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.18.1

go.sum

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
594594
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
595595
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975 h1:/Tl7pH94bvbAAHBdZJT947M/+gp0+CqQXDtMRC0fseo=
596596
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
597+
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
598+
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
597599
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
598600
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
599601
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@@ -852,15 +854,17 @@ k8s.io/kubectl v0.18.1/go.mod h1:7bLKKp5gSrtuSCIbclgifVOCwdLBs+h3oETVqLn1928=
852854
k8s.io/kubelet v0.18.1/go.mod h1:wlhv8yVMnbTp0haWYfuOzD7fqq7F35bWcIFIpdy9w9A=
853855
k8s.io/kubernetes v1.18.5 h1:sLbTilDIc02vNzrTORdW2YakzrPCOtmffaUXCwQHsRc=
854856
k8s.io/kubernetes v1.18.5/go.mod h1:Efg82S+Ti02A/Mww53bxroc7IgzX2bgPsf6hT8gAs3M=
855-
k8s.io/legacy-cloud-providers v0.0.0-20200711020551-224d5470706b h1:U6s1jf8ZIWD3G/5/vtRh75iDB3RfMP6Y9UpikHgh5to=
856-
k8s.io/legacy-cloud-providers v0.0.0-20200711020551-224d5470706b/go.mod h1:1PY7/iWuD99kgksPmcb90Jn3Xtl/yW1ICQvKWIwJGEU=
857+
k8s.io/legacy-cloud-providers v0.0.0-20200731174458-cce61a865d46 h1:ojY3Mxvwnh8f/mP1bVyptw8zzFSS6EyvtCdOxB26NQc=
858+
k8s.io/legacy-cloud-providers v0.0.0-20200731174458-cce61a865d46/go.mod h1:IJ/IyiwEloImiZd033RM/WAFc32p5KY1hlNIRtGUgT8=
857859
k8s.io/metrics v0.18.1/go.mod h1:UnoYSbaiakbuBYgpDEsXjVjk843af/WRHNPR3Wx+2XI=
858860
k8s.io/repo-infra v0.0.1-alpha.1/go.mod h1:wO1t9WaB99V80ljbeENTnayuEEwNZt7gECYh/CEyOJ8=
859861
k8s.io/sample-apiserver v0.18.1/go.mod h1:ir6PkLhIblVb9nNHzd8LG77QW4mhQAwahznNAIHhOEM=
860862
k8s.io/system-validators v1.0.4/go.mod h1:HgSgTg4NAGNoYYjKsUyk52gdNi2PVDswQ9Iyn66R7NI=
861863
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
862864
k8s.io/utils v0.0.0-20200619165400-6e3d28b6ed19 h1:7Nu2dTj82c6IaWvL7hImJzcXoTPz1MsSCH7r+0m6rfo=
863865
k8s.io/utils v0.0.0-20200619165400-6e3d28b6ed19/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
866+
k8s.io/utils v0.0.0-20200729134348-d5654de09c73 h1:uJmqzgNWG7XyClnU/mLPBWwfKKF1K8Hf8whTseBgJcg=
867+
k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
864868
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
865869
modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
866870
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=

pkg/blobfuse/blobfuse.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,21 @@ const (
4444
defaultDirMode = "0777"
4545
defaultVers = "3.0"
4646
serverNameField = "server"
47+
tagsField = "tags"
4748

4849
// See https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata#container-names
4950
containerNameMinLength = 3
5051
containerNameMaxLength = 63
52+
53+
accountNotProvisioned = "StorageAccountIsNotProvisioned"
54+
tooManyRequests = "TooManyRequests"
55+
shareNotFound = "The specified share does not exist"
56+
shareBeingDeleted = "The specified share is being deleted"
57+
clientThrottled = "client throttled"
58+
)
59+
60+
var (
61+
retriableErrors = []string{accountNotProvisioned, tooManyRequests, shareNotFound, shareBeingDeleted, clientThrottled}
5162
)
5263

5364
// Driver implements all interfaces of CSI drivers
@@ -395,3 +406,14 @@ func IsCorruptedDir(dir string) bool {
395406
fmt.Printf("IsCorruptedDir(%s) returned with error: (%v, %v)\\n", dir, pathExists, pathErr)
396407
return pathErr != nil && mount.IsCorruptedMnt(pathErr)
397408
}
409+
410+
func isRetriableError(err error) bool {
411+
if err != nil {
412+
for _, v := range retriableErrors {
413+
if strings.Contains(strings.ToLower(err.Error()), strings.ToLower(v)) {
414+
return true
415+
}
416+
}
417+
}
418+
return false
419+
}

pkg/blobfuse/blobfuse_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package blobfuse
1818

1919
import (
20+
"errors"
2021
"fmt"
2122
"io/ioutil"
2223
"os"
@@ -136,6 +137,53 @@ func TestGetContainerInfo(t *testing.T) {
136137
}
137138
}
138139

140+
func TestIsRetriableError(t *testing.T) {
141+
tests := []struct {
142+
desc string
143+
rpcErr error
144+
expectedBool bool
145+
}{
146+
{
147+
desc: "non-retriable error",
148+
rpcErr: nil,
149+
expectedBool: false,
150+
},
151+
{
152+
desc: "accountNotProvisioned",
153+
rpcErr: errors.New("could not get storage key for storage account : could not get storage key for storage account f233333: Retriable: true, RetryAfter: 0001-01-01 00:00:00 +0000 UTC, HTTPStatusCode: 409, RawError: storage.AccountsClient#ListKeys: Failure sending request: StatusCode=409 -- Original Error: autorest/azure: Service returned an error. Status=<nil> Code=\"StorageAccountIsNotProvisioned\" Message=\"The storage account provisioning state must be 'Succeeded' before executing the operation.\""),
154+
expectedBool: true,
155+
},
156+
{
157+
desc: "tooManyRequests",
158+
rpcErr: errors.New("could not get storage key for storage account : could not list storage accounts for account type Premium_LRS: Retriable: true, RetryAfter: 0001-01-01 00:00:00 +0000 UTC m=+231.866923225, HTTPStatusCode: 429, RawError: storage.AccountsClient#ListByResourceGroup: Failure responding to request: StatusCode=429 -- Original Error: autorest/azure: Service returned an error. Status=429 Code=\"TooManyRequests\" Message=\"The request is being throttled as the limit has been reached for operation type - List. For more information, see - https://aka.ms/srpthrottlinglimits\""),
159+
expectedBool: true,
160+
},
161+
{
162+
desc: "shareNotFound",
163+
rpcErr: errors.New("storage.FileSharesClient#Get: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code=\"ShareNotFound\" Message=\"The specified share does not exist\""),
164+
expectedBool: true,
165+
},
166+
{
167+
desc: "shareBeingDeleted",
168+
rpcErr: errors.New("storage.FileSharesClient#Create: Failure sending request: StatusCode=409 -- Original Error: autorest/azure: Service returned an error. Status=<nil> Code=\"ShareBeingDeleted\" Message=\"The specified share is being deleted. Try operation later.\""),
169+
expectedBool: true,
170+
},
171+
{
172+
desc: "clientThrottled",
173+
rpcErr: errors.New("could not list storage accounts for account type : Retriable: true, RetryAfter: 16s, HTTPStatusCode: 0, RawError: azure cloud provider throttled for operation StorageAccountListByResourceGroup with reason \"client throttled\""),
174+
expectedBool: true,
175+
},
176+
}
177+
178+
for _, test := range tests {
179+
result := isRetriableError(test.rpcErr)
180+
if result != test.expectedBool {
181+
t.Errorf("desc: (%s), input: rpcErr(%v), isRetriableError returned with bool(%v), not equal to expectedBool(%v)",
182+
test.desc, test.rpcErr, result, test.expectedBool)
183+
}
184+
}
185+
}
186+
139187
func TestGetValidContainerName(t *testing.T) {
140188
tests := []struct {
141189
volumeName string

pkg/blobfuse/controllerserver.go

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"google.golang.org/grpc/status"
3131
"k8s.io/apimachinery/pkg/util/wait"
3232
"k8s.io/klog/v2"
33+
"k8s.io/legacy-cloud-providers/azure"
3334
)
3435

3536
const blobfuseAccountNamePrefix = "fuse"
@@ -54,7 +55,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
5455
requestGiB := int(util.RoundUpGiB(volSizeBytes))
5556

5657
parameters := req.GetParameters()
57-
var storageAccountType, resourceGroup, location, accountName, containerName string
58+
var storageAccountType, resourceGroup, location, account, containerName, customTags string
5859

5960
// Apply ProvisionerParameters (case-insensitive). We leave validation of
6061
// the values to the cloud provider.
@@ -67,11 +68,13 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
6768
case "location":
6869
location = v
6970
case "storageaccount":
70-
accountName = v
71+
account = v
7172
case "resourcegroup":
7273
resourceGroup = v
7374
case "containername":
7475
containerName = v
76+
case tagsField:
77+
customTags = v
7578
}
7679
}
7780

@@ -83,11 +86,38 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
8386
if strings.HasPrefix(strings.ToLower(storageAccountType), "premium") {
8487
accountKind = string(storage.BlockBlobStorage)
8588
}
86-
account, accountKey, err := d.cloud.EnsureStorageAccount(accountName, storageAccountType, accountKind, resourceGroup, location, blobfuseAccountNamePrefix, false)
89+
90+
enableHTTPSTrafficOnly := true
91+
92+
tags, err := azure.ConvertTagsToMap(customTags)
93+
if err != nil {
94+
return nil, err
95+
}
96+
97+
accountOptions := &azure.AccountOptions{
98+
Name: account,
99+
Type: storageAccountType,
100+
Kind: accountKind,
101+
ResourceGroup: resourceGroup,
102+
Location: location,
103+
EnableHTTPSTrafficOnly: enableHTTPSTrafficOnly,
104+
Tags: tags,
105+
}
106+
107+
var accountName, accountKey string
108+
err = wait.ExponentialBackoff(d.cloud.RequestBackoff(), func() (bool, error) {
109+
var retErr error
110+
accountName, accountKey, retErr = d.cloud.EnsureStorageAccount(accountOptions, blobfuseAccountNamePrefix)
111+
if isRetriableError(retErr) {
112+
klog.Warningf("EnsureStorageAccount(%s) failed with error(%v), waiting for retrying", account, retErr)
113+
return false, nil
114+
}
115+
return true, retErr
116+
})
117+
87118
if err != nil {
88-
return nil, fmt.Errorf("could not get storage key for storage account %s: %v", accountName, err)
119+
return nil, status.Errorf(codes.Internal, "failed to ensure storage account: %v", err)
89120
}
90-
accountName = account
91121

92122
if containerName == "" {
93123
containerName = getValidContainerName(name)

vendor/golang.org/x/crypto/chacha20/chacha_arm64.go

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

vendor/golang.org/x/crypto/chacha20/chacha_arm64.s

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

0 commit comments

Comments
 (0)