From 139dfbd0e12ff4129cf33b41909f60fd8b9dfd10 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Wed, 26 Jul 2017 21:43:24 -0400 Subject: [PATCH] Update generic errors with the new http package codes All of these errors are now part of the standard HTTP method. Formalize those into our error types and remove duplication and unclear separation. Kubernetes-commit: d3be1ac92eb644e284915a55fe67942c33f88d4c --- pkg/endpoints/apiserver_test.go | 2 +- pkg/endpoints/installer.go | 2 +- pkg/server/filters/maxinflight.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/endpoints/apiserver_test.go b/pkg/endpoints/apiserver_test.go index 19980d543..361cb56d0 100644 --- a/pkg/endpoints/apiserver_test.go +++ b/pkg/endpoints/apiserver_test.go @@ -3749,7 +3749,7 @@ func TestCreateTimeout(t *testing.T) { if err != nil { t.Errorf("unexpected error: %v", err) } - itemOut := expectApiStatus(t, "POST", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/foo?timeout=4ms", data, apierrs.StatusServerTimeout) + itemOut := expectApiStatus(t, "POST", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/foo?timeout=4ms", data, http.StatusGatewayTimeout) if itemOut.Status != metav1.StatusFailure || itemOut.Reason != metav1.StatusReasonTimeout { t.Errorf("Unexpected status %#v", itemOut) } diff --git a/pkg/endpoints/installer.go b/pkg/endpoints/installer.go index 19515f5bf..5802aeb97 100644 --- a/pkg/endpoints/installer.go +++ b/pkg/endpoints/installer.go @@ -511,7 +511,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag // http.StatusUnsupportedMediaType, http.StatusNotAcceptable, // http.StatusBadRequest, http.StatusUnauthorized, http.StatusForbidden, // http.StatusRequestTimeout, http.StatusConflict, http.StatusPreconditionFailed, - // 422 (StatusUnprocessableEntity), http.StatusInternalServerError, + // http.StatusUnprocessableEntity, http.StatusInternalServerError, // http.StatusServiceUnavailable // and api error codes // Note that if we specify a versioned Status object here, we may need to diff --git a/pkg/server/filters/maxinflight.go b/pkg/server/filters/maxinflight.go index 3e159c21f..883a27dc3 100644 --- a/pkg/server/filters/maxinflight.go +++ b/pkg/server/filters/maxinflight.go @@ -123,5 +123,5 @@ func WithMaxInFlightLimit( func tooManyRequests(req *http.Request, w http.ResponseWriter) { // Return a 429 status indicating "Too Many Requests" w.Header().Set("Retry-After", retryAfter) - http.Error(w, "Too many requests, please try again later.", errors.StatusTooManyRequests) + http.Error(w, "Too many requests, please try again later.", http.StatusTooManyRequests) }