9918: Add RequestTimeout config for keep-balance.
authorTom Clegg <tclegg@veritasgenetics.com>
Fri, 18 May 2018 19:50:15 +0000 (15:50 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Fri, 18 May 2018 19:50:15 +0000 (15:50 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

services/keep-balance/main.go
services/keep-balance/usage.go

index 947033564df01e479d05682617fc041417e5d54f..90235cbf3188d91bc274412ddd5522dc639fa812 100644 (file)
@@ -9,6 +9,7 @@ import (
        "flag"
        "fmt"
        "log"
+       "net/http"
        "os"
        "os/signal"
        "syscall"
@@ -45,6 +46,9 @@ type Config struct {
        // more memory, but can reduce store-and-forward latency when
        // fetching pages)
        CollectionBuffers int
+
+       // Timeout for outgoing http request/response cycle.
+       RequestTimeout arvados.Duration
 }
 
 // RunOptions controls runtime behavior. The flags/options that belong
@@ -107,6 +111,14 @@ func main() {
                log.Fatal(config.DumpAndExit(cfg))
        }
 
+       to := time.Duration(cfg.RequestTimeout)
+       if to == 0 {
+               to = 30 * time.Minute
+       }
+       arvados.DefaultSecureClient.Timeout = to
+       arvados.InsecureHTTPClient.Timeout = to
+       http.DefaultClient.Timeout = to
+
        log.Printf("keep-balance %s started", version)
 
        if *debugFlag {
index 0f4effe6f4e9b7c4e2590cfeb48ef5cd729ec5cd..4c7d5067182fe89783e104c56063fdaf86545c1b 100644 (file)
@@ -19,7 +19,8 @@ KeepServiceTypes:
     - disk
 RunPeriod: 600s
 CollectionBatchSize: 100000
-CollectionBuffers: 1000`)
+CollectionBuffers: 1000
+RequestTimeout: 30m`)
 
 func usage() {
        fmt.Fprintf(os.Stderr, `
@@ -86,6 +87,11 @@ Tuning resource usage:
     while the current page is still being processed. If this is zero
     or omitted, pages are processed serially.
 
+    RequestTimeout is the maximum time keep-balance will spend on a
+    single HTTP request (getting a page of collections, getting the
+    block index from a keepstore server, or sending a trash or pull
+    list to a keepstore server). Defaults to 30 minutes.
+
 Limitations:
 
     keep-balance does not attempt to discover whether committed pull