From ea76b5a6935d5535123e2f2ecf283e68eb69731a Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 10 Aug 2017 11:46:38 -0700 Subject: [PATCH 1/2] Show scp output on error --- communicator/ssh/communicator.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/communicator/ssh/communicator.go b/communicator/ssh/communicator.go index a6a7f9cf9..99ce03f67 100644 --- a/communicator/ssh/communicator.go +++ b/communicator/ssh/communicator.go @@ -693,6 +693,11 @@ func (c *comm) scpSession(scpCommand string, f func(io.Writer, *bufio.Reader) er // Otherwise, we have an ExitErorr, meaning we can just read // the exit status log.Printf("non-zero exit status: %d", exitErr.ExitStatus()) + stdoutB, err := ioutil.ReadAll(stdoutR) + if err != nil { + return err + } + log.Printf("scp output: %s", stdoutB) // If we exited with status 127, it means SCP isn't available. // Return a more descriptive error for that. From 2d3b639c7bb484f2461785e0561185423c370619 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 10 Aug 2017 17:02:23 -0700 Subject: [PATCH 2/2] don't need a waitgroup for uploading files --- packer/rpc/communicator.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/packer/rpc/communicator.go b/packer/rpc/communicator.go index bb085bd49..fbfe0c538 100644 --- a/packer/rpc/communicator.go +++ b/packer/rpc/communicator.go @@ -111,8 +111,7 @@ func (c *communicator) Start(cmd *packer.RemoteCmd) (err error) { var finished CommandFinished decoder := gob.NewDecoder(conn) - err = decoder.Decode(&finished) - if err != nil { + if err := decoder.Decode(&finished); err != nil { log.Printf("[ERR] Error decoding response stream %d: %s", responseStreamId, err) cmd.SetExited(123) @@ -130,12 +129,7 @@ func (c *communicator) Start(cmd *packer.RemoteCmd) (err error) { func (c *communicator) Upload(path string, r io.Reader, fi *os.FileInfo) (err error) { // Pipe the reader through to the connection streamId := c.mux.NextId() - var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - serveSingleCopy("uploadData", c.mux, streamId, nil, r) - }() + go serveSingleCopy("uploadData", c.mux, streamId, nil, r) args := CommunicatorUploadArgs{ Path: path, @@ -147,7 +141,6 @@ func (c *communicator) Upload(path string, r io.Reader, fi *os.FileInfo) (err er } err = c.client.Call("Communicator.Upload", &args, new(interface{})) - wg.Wait() return }