mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #86685 from yangl900/stop-retry-bad-request
Azure cloud provider should not retry on bad request
This commit is contained in:
commit
0a496e3860
@ -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
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user