Unverified Commit fcc9f166 authored by Kubernetes Prow Robot's avatar Kubernetes Prow Robot Committed by GitHub

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

fix azure retry issue when return 2XX with error
parents 6a5fa6ca 8a45ba19
...@@ -596,8 +596,9 @@ func shouldRetryHTTPRequest(resp *http.Response, err error) bool { ...@@ -596,8 +596,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
} }
...@@ -620,7 +621,7 @@ func (az *Cloud) processHTTPRetryResponse(service *v1.Service, reason string, re ...@@ -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 { 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
} }
......
...@@ -120,6 +120,11 @@ func TestProcessRetryResponse(t *testing.T) { ...@@ -120,6 +120,11 @@ func TestProcessRetryResponse(t *testing.T) {
stop: true, stop: true,
}, },
{ {
code: http.StatusOK,
err: fmt.Errorf("some error"),
stop: false,
},
{
code: 399, code: 399,
stop: true, stop: true,
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment