Merge pull request #5238 from hashicorp/fix5237

do not wait for rpc upload command to return
This commit is contained in:
Megan Marsh 2017-08-11 09:33:35 -07:00 committed by GitHub
commit d733be711a
2 changed files with 7 additions and 9 deletions

View File

@ -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.

View File

@ -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
}