Add an idle timeout for the server (#4760)

* Add an idle timeout for the server

Because tidy operations can be long-running, this also changes all tidy
operations to behave the same operationally (kick off the process, get a
warning back, log errors to server log) and makes them all run in a
goroutine.

This could mean a sort of hard stop if Vault gets sealed because the
function won't have the read lock. This should generally be okay
(running tidy again should pick back up where it left off), but future
work could use cleanup funcs to trigger the functions to stop.

* Fix up tidy test

* Add deadline to cluster connections and an idle timeout to the cluster server, plus add readheader/read timeout to api server
This commit is contained in:
Jeff Mitchell
2018-06-16 18:21:33 -04:00
committed by GitHub
parent 43e218e5b1
commit f493d2436e
18 changed files with 1212 additions and 1223 deletions

View File

@@ -3,6 +3,7 @@ package approle
import (
"context"
"testing"
"time"
"github.com/hashicorp/vault/logical"
)
@@ -64,11 +65,14 @@ func TestAppRole_TidyDanglingAccessors(t *testing.T) {
t.Fatalf("bad: len(accessorHashes); expect 3, got %d", len(accessorHashes))
}
err = b.tidySecretID(context.Background(), storage)
_, err = b.tidySecretID(context.Background(), storage)
if err != nil {
t.Fatal(err)
}
// It runs async so we give it a bit of time to run
time.Sleep(10 * time.Second)
accessorHashes, err = storage.List(context.Background(), "accessor/")
if err != nil {
t.Fatal(err)