diff --git a/builder/amazon/chroot/communicator.go b/builder/amazon/chroot/communicator.go index b77ee03e8..24284efab 100644 --- a/builder/amazon/chroot/communicator.go +++ b/builder/amazon/chroot/communicator.go @@ -69,7 +69,10 @@ func (c *Communicator) Upload(dst string, r io.Reader, fi *os.FileInfo) error { return fmt.Errorf("Error preparing shell script: %s", err) } defer os.Remove(tf.Name()) - io.Copy(tf, r) + + if _, err := io.Copy(tf, r); err != nil { + return err + } cpCmd, err := c.CmdWrapper(fmt.Sprintf("cp %s %s", tf.Name(), dst)) if err != nil { diff --git a/builder/amazon/common/step_run_source_instance.go b/builder/amazon/common/step_run_source_instance.go index 8ac837875..0f33611a2 100644 --- a/builder/amazon/common/step_run_source_instance.go +++ b/builder/amazon/common/step_run_source_instance.go @@ -342,7 +342,10 @@ func (s *StepRunSourceInstance) Cleanup(state multistep.StateBag) { Target: "cancelled", } - WaitForState(&stateChange) + _, err := WaitForState(&stateChange) + if err != nil { + ui.Error(err.Error()) + } } @@ -359,6 +362,9 @@ func (s *StepRunSourceInstance) Cleanup(state multistep.StateBag) { Target: "terminated", } - WaitForState(&stateChange) + _, err := WaitForState(&stateChange) + if err != nil { + ui.Error(err.Error()) + } } } diff --git a/communicator/ssh/communicator.go b/communicator/ssh/communicator.go index 9cef308fb..d9fc0442d 100644 --- a/communicator/ssh/communicator.go +++ b/communicator/ssh/communicator.go @@ -250,7 +250,7 @@ func (c *comm) newSession() (session *ssh.Session, err error) { func (c *comm) reconnect() (err error) { if c.conn != nil { - c.conn.Close() + return c.conn.Close() } // Set the conn and client to nil since we'll recreate it