13493: Return 502 Bad Gateway on proxy connection/proto failure.
authorTom Clegg <tclegg@veritasgenetics.com>
Fri, 6 Jul 2018 20:42:33 +0000 (16:42 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Fri, 6 Jul 2018 20:42:33 +0000 (16:42 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

lib/controller/federation_test.go
lib/controller/handler_test.go
lib/controller/proxy.go

index 3848e03934db64ba64fc04ee7cdd7ffa3508cdaa..8ca1aa52360f3c74a71e27021fa89bce912df93b 100644 (file)
@@ -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`)
 }
 
index c132b659dad64ef192efdd885de262859cc541b2..3aedfb8894e7cd353712198b702655b0e8e7df78 100644 (file)
@@ -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)
index 7905f91d0575e70cd5348ce0eafcf2c57f6f5490..1ff383d8961a3d620435edc174f4377a7422f212 100644 (file)
@@ -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 {