Merge pull request #78298 from andyzhangx/azure-retry-issue

fix azure retry issue when return 2XX with error
This commit is contained in:
Kubernetes Prow Robot 2019-05-28 01:02:28 -07:00 committed by GitHub
commit fcc9f166fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -596,8 +596,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
}
@ -620,7 +621,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
}

View File

@ -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,