Skip to content

Commit 54b28ab

Browse files
authored
Merge pull request kubernetes#81279 from feiskyer/fix-precondition-cancel
Fix Azure client requests stuck issues on http.StatusTooManyRequests
2 parents 461b2d8 + e53c57a commit 54b28ab

File tree

1 file changed

+15
-0
lines changed
  • staging/src/k8s.io/legacy-cloud-providers/azure

1 file changed

+15
-0
lines changed

staging/src/k8s.io/legacy-cloud-providers/azure/azure.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"io"
2222
"io/ioutil"
23+
"net/http"
2324
"strings"
2425
"sync"
2526
"time"
@@ -238,6 +239,20 @@ type Cloud struct {
238239
}
239240

240241
func init() {
242+
// In go-autorest SDK https://github.com/Azure/go-autorest/blob/master/autorest/sender.go#L258-L287,
243+
// if ARM returns http.StatusTooManyRequests, the sender doesn't increase the retry attempt count,
244+
// hence the Azure clients will keep retrying forever until it get a status code other than 429.
245+
// So we explicitly removes http.StatusTooManyRequests from autorest.StatusCodesForRetry.
246+
// Refer https://github.com/Azure/go-autorest/issues/398.
247+
// TODO(feiskyer): Use autorest.SendDecorator to customize the retry policy when new Azure SDK is available.
248+
statusCodesForRetry := make([]int, 0)
249+
for _, code := range autorest.StatusCodesForRetry {
250+
if code != http.StatusTooManyRequests {
251+
statusCodesForRetry = append(statusCodesForRetry, code)
252+
}
253+
}
254+
autorest.StatusCodesForRetry = statusCodesForRetry
255+
241256
cloudprovider.RegisterCloudProvider(CloudProviderName, NewCloud)
242257
}
243258

0 commit comments

Comments
 (0)