fix azure retry issue when return 2XX with error

fix comments
pull/564/head
andyzhangx 2019-05-24 12:47:08 +00:00
parent 4ccdc8b71b
commit 74a785b925
2 changed files with 8 additions and 2 deletions

View File

@ -552,8 +552,9 @@ func shouldRetryHTTPRequest(resp *http.Response, err error) bool {
return false 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) { 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 // HTTP 2xx suggests a successful response
return true, nil return true, nil
} }
@ -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 { 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 // HTTP 2xx suggests a successful response
return nil return nil
} }

View File

@ -119,6 +119,11 @@ func TestProcessRetryResponse(t *testing.T) {
code: http.StatusOK, code: http.StatusOK,
stop: true, stop: true,
}, },
{
code: http.StatusOK,
err: fmt.Errorf("some error"),
stop: false,
},
{ {
code: 399, code: 399,
stop: true, stop: true,