mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #81265 from jfbai/replace-status-too-many-request
Replace self defined const StatusTooManyRequests with http.StatusTooM…
This commit is contained in:
commit
a6aea3fcd8
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package eventratelimit
|
package eventratelimit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -516,7 +517,7 @@ func TestEventRateLimiting(t *testing.T) {
|
|||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
statusErr, ok := err.(*errors.StatusError)
|
statusErr, ok := err.(*errors.StatusError)
|
||||||
if ok && statusErr.ErrStatus.Code != errors.StatusTooManyRequests {
|
if ok && statusErr.ErrStatus.Code != http.StatusTooManyRequests {
|
||||||
t.Fatalf("%v: Request %v should yield a 429 response: %v", tc.name, rqIndex, err)
|
t.Fatalf("%v: Request %v should yield a 429 response: %v", tc.name, rqIndex, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,9 @@ import (
|
|||||||
const (
|
const (
|
||||||
// StatusTooManyRequests means the server experienced too many requests within a
|
// StatusTooManyRequests means the server experienced too many requests within a
|
||||||
// given window and that the client must wait to perform the action again.
|
// given window and that the client must wait to perform the action again.
|
||||||
StatusTooManyRequests = 429
|
// DEPRECATED: please use http.StatusTooManyRequests, this will be removed in
|
||||||
|
// the future version.
|
||||||
|
StatusTooManyRequests = http.StatusTooManyRequests
|
||||||
)
|
)
|
||||||
|
|
||||||
// StatusError is an error intended for consumption by a REST API server; it can also be
|
// StatusError is an error intended for consumption by a REST API server; it can also be
|
||||||
@ -349,7 +351,7 @@ func NewTimeoutError(message string, retryAfterSeconds int) *StatusError {
|
|||||||
func NewTooManyRequestsError(message string) *StatusError {
|
func NewTooManyRequestsError(message string) *StatusError {
|
||||||
return &StatusError{metav1.Status{
|
return &StatusError{metav1.Status{
|
||||||
Status: metav1.StatusFailure,
|
Status: metav1.StatusFailure,
|
||||||
Code: StatusTooManyRequests,
|
Code: http.StatusTooManyRequests,
|
||||||
Reason: metav1.StatusReasonTooManyRequests,
|
Reason: metav1.StatusReasonTooManyRequests,
|
||||||
Message: fmt.Sprintf("Too many requests: %s", message),
|
Message: fmt.Sprintf("Too many requests: %s", message),
|
||||||
}}
|
}}
|
||||||
|
Loading…
Reference in New Issue
Block a user