Merge pull request #86685 from yangl900/stop-retry-bad-request

Azure cloud provider should not retry on bad request
This commit is contained in:
Kubernetes Prow Robot 2019-12-28 04:17:39 -08:00 committed by GitHub
commit 0a496e3860
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -125,8 +125,9 @@ func getHTTPStatusCode(resp *http.Response) int {
// shouldRetryHTTPRequest determines if the request is retriable.
func shouldRetryHTTPRequest(resp *http.Response, err error) bool {
if resp != nil {
// HTTP 412 (StatusPreconditionFailed) means etag mismatch, hence we shouldn't retry.
if resp.StatusCode == http.StatusPreconditionFailed {
// HTTP 412 (StatusPreconditionFailed) means etag mismatch
// HTTP 400 (BadRequest) means the request cannot be accepted, hence we shouldn't retry.
if resp.StatusCode == http.StatusPreconditionFailed || resp.StatusCode == http.StatusBadRequest {
return false
}

View File

@ -54,7 +54,7 @@ func TestGetError(t *testing.T) {
{
code: http.StatusBadRequest,
expected: &Error{
Retriable: true,
Retriable: false,
HTTPStatusCode: http.StatusBadRequest,
RawError: fmt.Errorf("HTTP response: 400"),
},
@ -136,7 +136,7 @@ func TestGetStatusNotFoundAndForbiddenIgnoredError(t *testing.T) {
{
code: http.StatusBadRequest,
expected: &Error{
Retriable: true,
Retriable: false,
HTTPStatusCode: http.StatusBadRequest,
RawError: fmt.Errorf("HTTP response: 400"),
},
@ -191,7 +191,7 @@ func TestShouldRetryHTTPRequest(t *testing.T) {
}{
{
code: http.StatusBadRequest,
expected: true,
expected: false,
},
{
code: http.StatusInternalServerError,