Skip to content

Commit

Permalink
Merge pull request #78422 from andyzhangx/automated-cherry-pick-of-#7…
Browse files Browse the repository at this point in the history
…8298-upstream-release-1.14

Automated cherry pick of #78298: fix azure retry issue when return 2XX with error
  • Loading branch information
k8s-ci-robot committed May 31, 2019
2 parents 0096daf + 74a785b commit 801f4e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/cloudprovider/providers/azure/azure_backoff.go
Expand Up @@ -552,8 +552,9 @@ func shouldRetryHTTPRequest(resp *http.Response, err error) bool {
return false
}

// processHTTPRetryResponse : return true means stop retry, false means continue retry
func (az *Cloud) processHTTPRetryResponse(service *v1.Service, reason string, resp *http.Response, err error) (bool, error) {
if resp != nil && isSuccessHTTPResponse(resp) {
if err == nil && resp != nil && isSuccessHTTPResponse(resp) {
// HTTP 2xx suggests a successful response
return true, nil
}
Expand All @@ -576,7 +577,7 @@ func (az *Cloud) processHTTPRetryResponse(service *v1.Service, reason string, re
}

func (az *Cloud) processHTTPResponse(service *v1.Service, reason string, resp *http.Response, err error) error {
if isSuccessHTTPResponse(resp) {
if err == nil && isSuccessHTTPResponse(resp) {
// HTTP 2xx suggests a successful response
return nil
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/cloudprovider/providers/azure/azure_backoff_test.go
Expand Up @@ -119,6 +119,11 @@ func TestProcessRetryResponse(t *testing.T) {
code: http.StatusOK,
stop: true,
},
{
code: http.StatusOK,
err: fmt.Errorf("some error"),
stop: false,
},
{
code: 399,
stop: true,
Expand Down

0 comments on commit 801f4e7

Please sign in to comment.