diff --git a/storage/rethinkdb/bootstrap.go b/storage/rethinkdb/bootstrap.go index fcc08e4c05..e7cd50f985 100644 --- a/storage/rethinkdb/bootstrap.go +++ b/storage/rethinkdb/bootstrap.go @@ -3,25 +3,22 @@ package rethinkdb import ( "fmt" "strings" + "time" "github.com/Sirupsen/logrus" "gopkg.in/dancannon/gorethink.v2" ) +// Wait for 60 seconds maximum on Wait() calls for rethink +var timeoutOpt = gorethink.WaitOpts{Timeout: time.Minute.Seconds()} + func makeDB(session *gorethink.Session, name string) error { _, err := gorethink.DBCreate(name).RunWrite(session) if err != nil { if strings.Contains(err.Error(), "already exists") { return nil } - - return err } - resp, err := gorethink.DB(name).Wait().Run(session) - if resp != nil { - resp.Close() - } - return err } @@ -41,7 +38,7 @@ func (t Table) term(dbName string) gorethink.Term { } func (t Table) wait(session *gorethink.Session, dbName string) error { - resp, err := t.term(dbName).Wait().Run(session) + resp, err := t.term(dbName).Wait(timeoutOpt).Run(session) if resp != nil { resp.Close()