From de0c0d75b30af4a8f264b9aefc7ae6c6e76525b1 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Fri, 23 Mar 2018 12:31:00 -0700 Subject: [PATCH] agent: backoff session when no remotes are available Signed-off-by: Stephen J Day --- agent/session.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/agent/session.go b/agent/session.go index 9bb9773a6c..8606eab392 100644 --- a/agent/session.go +++ b/agent/session.go @@ -67,7 +67,14 @@ func newSession(ctx context.Context, agent *Agent, delay time.Duration, sessionI ) if err != nil { - s.errs <- err + // since we are returning without launching the session goroutine, we + // need to provide the delay that is guaranteed by calling this + // function. We launch a goroutine so that we only delay the retry and + // avoid blocking the main loop. + go func() { + time.Sleep(delay) + s.errs <- err + }() return s }