Merge pull request #20417 from hashicorp/jbardin/scp-error
print scp error before exiting on error code
This commit is contained in:
commit
092596adad
|
@ -481,6 +481,13 @@ func (c *Communicator) scpSession(scpCommand string, f func(io.Writer, *bufio.Re
|
||||||
// our data and has completed. Or has errored.
|
// our data and has completed. Or has errored.
|
||||||
log.Println("[DEBUG] Waiting for SSH session to complete.")
|
log.Println("[DEBUG] Waiting for SSH session to complete.")
|
||||||
err = session.Wait()
|
err = session.Wait()
|
||||||
|
|
||||||
|
// log any stderr before exiting on an error
|
||||||
|
scpErr := stderr.String()
|
||||||
|
if len(scpErr) > 0 {
|
||||||
|
log.Printf("[ERROR] scp stderr: %q", stderr)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if exitErr, ok := err.(*ssh.ExitError); ok {
|
if exitErr, ok := err.(*ssh.ExitError); ok {
|
||||||
// Otherwise, we have an ExitErorr, meaning we can just read
|
// Otherwise, we have an ExitErorr, meaning we can just read
|
||||||
|
@ -499,11 +506,6 @@ func (c *Communicator) scpSession(scpCommand string, f func(io.Writer, *bufio.Re
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
scpErr := stderr.String()
|
|
||||||
if len(scpErr) > 0 {
|
|
||||||
log.Printf("[ERROR] scp stderr: %q", stderr)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue