1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-22 15:57:07 +00:00

sftp: persist "ssh command exited" error

If our ssh process has died, not only the next, but all subsequent
calls to clientError() should indicate the error.

restic output when the ssh process is killed with "kill -9":

  Save(<data/afb68adbf9>) returned error, retrying after 253.661803ms: Write: failed to send packet header: write |1: file already closed
  Save(<data/afb68adbf9>) returned error, retrying after 580.752212ms: ssh command exited: signal: killed
  Save(<data/afb68adbf9>) returned error, retrying after 790.150468ms: ssh command exited: signal: killed
  Save(<data/afb68adbf9>) returned error, retrying after 1.769595051s: ssh command exited: signal: killed
  [...]
  error in cleanup handler: ssh command exited: signal: killed

Before this patch:

  Save(<data/de698d934f>) returned error, retrying after 252.84163ms: Write: failed to send packet header: write |1: file already closed
  Save(<data/de698d934f>) returned error, retrying after 660.236963ms: OpenFile: failed to send packet header: write |1: file already closed
  Save(<data/de698d934f>) returned error, retrying after 568.049909ms: OpenFile: failed to send packet header: write |1: file already closed
  Save(<data/de698d934f>) returned error, retrying after 2.428813824s: OpenFile: failed to send packet header: write |1: file already closed
  [...]
  error in cleanup handler: failed to send packet header: write |1: file already closed
This commit is contained in:
Jakob Unterwurzacher 2018-05-30 19:28:14 +02:00
parent 185b60c22b
commit dd3b9910ee

View file

@ -75,7 +75,9 @@ func startClient(program string, args ...string) (*SFTP, error) {
go func() { go func() {
err := cmd.Wait() err := cmd.Wait()
debug.Log("ssh command exited, err %v", err) debug.Log("ssh command exited, err %v", err)
ch <- errors.Wrap(err, "cmd.Wait") for {
ch <- errors.Wrap(err, "ssh command exited")
}
}() }()
// open the SFTP session // open the SFTP session