From 449eceec118dfb5b767e4f5db9e80b6f2f120a21 Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Mon, 22 May 2017 23:59:54 +0200 Subject: [PATCH] agent: shutdown delegate if created When the TestAgent shuts down a half-started agent the delegate may not have been created at this point. --- command/agent/agent.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/command/agent/agent.go b/command/agent/agent.go index 286e0a6ac..3af539e4c 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -1011,8 +1011,11 @@ func (a *Agent) Shutdown() error { chk.Stop() } - err := a.delegate.Shutdown() - a.logger.Print("[DEBUG] agent: delegate down") + var err error + if a.delegate != nil { + err = a.delegate.Shutdown() + a.logger.Print("[DEBUG] agent: delegate down") + } pidErr := a.deletePid() if pidErr != nil {