19972: Disable auto-retry in ws and dispatcher.
authorTom Clegg <tom@curii.com>
Tue, 28 Feb 2023 21:04:10 +0000 (16:04 -0500)
committerTom Clegg <tom@curii.com>
Wed, 8 Mar 2023 14:10:28 +0000 (09:10 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

lib/dispatchcloud/cmd.go
lib/dispatchcloud/dispatcher_test.go
services/ws/permission.go
services/ws/permission_test.go
services/ws/service.go

index 0254c6526c19103d336ea14fac445877c685376a..81982cdc1a7dad1a52c1b9bf05d34879ef7924ba 100644 (file)
@@ -21,6 +21,10 @@ func newHandler(ctx context.Context, cluster *arvados.Cluster, token string, reg
        if err != nil {
                return service.ErrorHandler(ctx, cluster, fmt.Errorf("error initializing client from cluster config: %s", err))
        }
+       // Disable auto-retry.  We have transient failure recovery at
+       // the application level, so we would rather receive/report
+       // upstream errors right away.
+       ac.Timeout = 0
        d := &dispatcher{
                Cluster:   cluster,
                Context:   ctx,
index a9ed95c7c3b5f581c4e3a60776f0d5c207c34db9..9d7d3736b05f15ac04c189bee9993b21bb8c35a1 100644 (file)
@@ -101,7 +101,8 @@ func (s *DispatcherSuite) SetUpTest(c *check.C) {
        arvadostest.SetServiceURL(&s.cluster.Services.Controller, "https://"+os.Getenv("ARVADOS_API_HOST")+"/")
 
        arvClient, err := arvados.NewClientFromConfig(s.cluster)
-       c.Check(err, check.IsNil)
+       c.Assert(err, check.IsNil)
+       arvClient.Timeout = 0 // disable auto-retry
 
        s.error503Server = httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusServiceUnavailable) }))
        arvClient.Client = &http.Client{
index ac895f80e5fd7ae7933558fbfa6e6acb97a6c7b0..78158b12a1921748d46bfe579ded1d3ed1c5982e 100644 (file)
@@ -75,7 +75,9 @@ func (pc *cachingPermChecker) Check(ctx context.Context, uuid string) (bool, err
        }
 
        pc.nMisses++
-       err = pc.RequestAndDecode(&buf, "GET", path, nil, url.Values{
+       ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Minute))
+       defer cancel()
+       err = pc.RequestAndDecodeContext(ctx, &buf, "GET", path, nil, url.Values{
                "include_trash": {"true"},
                "select":        {`["uuid"]`},
        })
index 023656c01fd93dc3a912283682ffc9eda59c7e6b..2e08cea484c0fd93403d85dd8295e7426edfeb21 100644 (file)
@@ -17,7 +17,9 @@ var _ = check.Suite(&permSuite{})
 type permSuite struct{}
 
 func (s *permSuite) TestCheck(c *check.C) {
-       pc := newPermChecker(*(arvados.NewClientFromEnv())).(*cachingPermChecker)
+       client := arvados.NewClientFromEnv()
+       client.Timeout = 0 // disable auto-retry
+       pc := newPermChecker(*client).(*cachingPermChecker)
        setToken := func(label, token string) {
                c.Logf("...%s token %q", label, token)
                pc.SetToken(token)
index 761e22e16c2cd4fd5025341e9ad284eb74b6f8c7..d6501e0771d59dab816d2d31fdf000770bad18fe 100644 (file)
@@ -7,6 +7,7 @@ package ws
 import (
        "context"
        "fmt"
+       "time"
 
        "git.arvados.org/arvados.git/lib/cmd"
        "git.arvados.org/arvados.git/lib/service"
@@ -24,6 +25,7 @@ func newHandler(ctx context.Context, cluster *arvados.Cluster, token string, reg
        if err != nil {
                return service.ErrorHandler(ctx, cluster, fmt.Errorf("error initializing client from cluster config: %s", err))
        }
+       client.Timeout = time.Minute
        eventSource := &pgEventSource{
                DataSource:   cluster.PostgreSQL.Connection.String(),
                MaxOpenConns: cluster.PostgreSQL.ConnectionPool,