From: Tom Clegg Date: Fri, 6 Jul 2018 20:42:33 +0000 (-0400) Subject: 13493: Return 502 Bad Gateway on proxy connection/proto failure. X-Git-Tag: 1.2.0~64^2~9 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/81d5bd428962c1819c0c60de5bc5d93710798424 13493: Return 502 Bad Gateway on proxy connection/proto failure. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- diff --git a/lib/controller/federation_test.go b/lib/controller/federation_test.go index 3848e03934..8ca1aa5236 100644 --- a/lib/controller/federation_test.go +++ b/lib/controller/federation_test.go @@ -109,7 +109,7 @@ func (s *FederationSuite) checkHandledLocally(c *check.C, resp *http.Response) { // it doesn't have its own stub/test Rails API, so we rely on // "connection refused" to indicate the controller tried to // proxy the request to its local Rails API. - c.Check(resp.StatusCode, check.Equals, http.StatusInternalServerError) + c.Check(resp.StatusCode, check.Equals, http.StatusBadGateway) s.checkJSONErrorMatches(c, resp, `.*connection refused`) } @@ -152,7 +152,7 @@ func (s *FederationSuite) TestRemoteError(c *check.C) { req := httptest.NewRequest("GET", "/arvados/v1/workflows/"+arvadostest.WorkflowWithDefinitionYAMLUUID, nil) req.Header.Set("Authorization", "Bearer "+arvadostest.ActiveToken) resp := s.testRequest(req) - c.Check(resp.StatusCode, check.Equals, http.StatusInternalServerError) + c.Check(resp.StatusCode, check.Equals, http.StatusBadGateway) s.checkJSONErrorMatches(c, resp, `.*HTTP response to HTTPS client`) } diff --git a/lib/controller/handler_test.go b/lib/controller/handler_test.go index c132b659da..3aedfb8894 100644 --- a/lib/controller/handler_test.go +++ b/lib/controller/handler_test.go @@ -65,7 +65,7 @@ func (s *HandlerSuite) TestRequestTimeout(c *check.C) { req := httptest.NewRequest("GET", "/discovery/v1/apis/arvados/v1/rest", nil) resp := httptest.NewRecorder() s.handler.ServeHTTP(resp, req) - c.Check(resp.Code, check.Equals, http.StatusInternalServerError) + c.Check(resp.Code, check.Equals, http.StatusBadGateway) var jresp httpserver.ErrorResponse err := json.Unmarshal(resp.Body.Bytes(), &jresp) c.Check(err, check.IsNil) diff --git a/lib/controller/proxy.go b/lib/controller/proxy.go index 7905f91d05..1ff383d896 100644 --- a/lib/controller/proxy.go +++ b/lib/controller/proxy.go @@ -63,7 +63,7 @@ func (p *proxy) Do(w http.ResponseWriter, reqIn *http.Request, urlOut *url.URL, }).WithContext(ctx) resp, err := client.Do(reqOut) if err != nil { - httpserver.Error(w, err.Error(), http.StatusInternalServerError) + httpserver.Error(w, err.Error(), http.StatusBadGateway) return } for k, v := range resp.Header {