[ARVADOS] updated: 2.1.0-971-g47e278f42
Git user
git at public.arvados.org
Mon Jun 21 15:25:58 UTC 2021
Summary of changes:
services/keepproxy/keepproxy.go | 11 +++++++----
services/keepproxy/keepproxy_test.go | 7 +++++--
2 files changed, 12 insertions(+), 6 deletions(-)
via 47e278f4286ec2c53c1faefd740b5119cb757b0a (commit)
from 2ffe1a900d4cfcceac02b44768a13a47edf18184 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 47e278f4286ec2c53c1faefd740b5119cb757b0a
Author: Peter Amstutz <peter.amstutz at curii.com>
Date: Mon Jun 21 11:25:29 2021 -0400
17464: MakeRESTRouter returns erro instead of panicking
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>
diff --git a/services/keepproxy/keepproxy.go b/services/keepproxy/keepproxy.go
index 04c95cfee..21bbfe40c 100644
--- a/services/keepproxy/keepproxy.go
+++ b/services/keepproxy/keepproxy.go
@@ -163,7 +163,10 @@ func run(logger log.FieldLogger, cluster *arvados.Cluster) error {
signal.Notify(term, syscall.SIGINT)
// Start serving requests.
- router = MakeRESTRouter(kc, time.Duration(keepclient.DefaultProxyRequestTimeout), cluster, logger)
+ router, err = MakeRESTRouter(kc, time.Duration(keepclient.DefaultProxyRequestTimeout), cluster, logger)
+ if err != nil {
+ return err
+ }
return http.Serve(listener, httpserver.AddRequestIDs(httpserver.LogRequests(router)))
}
@@ -311,7 +314,7 @@ type proxyHandler struct {
// MakeRESTRouter returns an http.Handler that passes GET and PUT
// requests to the appropriate handlers.
-func MakeRESTRouter(kc *keepclient.KeepClient, timeout time.Duration, cluster *arvados.Cluster, logger log.FieldLogger) http.Handler {
+func MakeRESTRouter(kc *keepclient.KeepClient, timeout time.Duration, cluster *arvados.Cluster, logger log.FieldLogger) (http.Handler, error) {
rest := mux.NewRouter()
transport := defaultTransport
@@ -325,7 +328,7 @@ func MakeRESTRouter(kc *keepclient.KeepClient, timeout time.Duration, cluster *a
cacheQ, err := lru.New2Q(500)
if err != nil {
- panic("Could not create 2Q")
+ return nil, fmt.Errorf("Error from lru.New2Q: %v", err)
}
h := &proxyHandler{
@@ -362,7 +365,7 @@ func MakeRESTRouter(kc *keepclient.KeepClient, timeout time.Duration, cluster *a
}).Methods("GET")
rest.NotFoundHandler = InvalidPathHandler{}
- return h
+ return h, nil
}
var errLoopDetected = errors.New("loop detected")
diff --git a/services/keepproxy/keepproxy_test.go b/services/keepproxy/keepproxy_test.go
index 67018f93c..9dc07ddaa 100644
--- a/services/keepproxy/keepproxy_test.go
+++ b/services/keepproxy/keepproxy_test.go
@@ -26,6 +26,7 @@ import (
"git.arvados.org/arvados.git/sdk/go/keepclient"
log "github.com/sirupsen/logrus"
+ "gopkg.in/check.v1"
. "gopkg.in/check.v1"
)
@@ -264,7 +265,8 @@ func (s *ServerRequiredSuite) TestPutWrongContentLength(c *C) {
// fixes the invalid Content-Length header. In order to test
// our server behavior, we have to call the handler directly
// using an httptest.ResponseRecorder.
- rtr := MakeRESTRouter(kc, 10*time.Second, &arvados.Cluster{}, log.New())
+ rtr, err := MakeRESTRouter(kc, 10*time.Second, &arvados.Cluster{}, log.New())
+ c.Assert(err, check.IsNil)
type testcase struct {
sendLength string
@@ -781,7 +783,8 @@ func (s *ServerRequiredSuite) TestPing(c *C) {
kc, _ := runProxy(c, false, false, nil)
defer closeListener()
- rtr := MakeRESTRouter(kc, 10*time.Second, &arvados.Cluster{ManagementToken: arvadostest.ManagementToken}, log.New())
+ rtr, err := MakeRESTRouter(kc, 10*time.Second, &arvados.Cluster{ManagementToken: arvadostest.ManagementToken}, log.New())
+ c.Assert(err, check.IsNil)
req, err := http.NewRequest("GET",
"http://"+listener.Addr().String()+"/_health/ping",
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list