Merge pull request #5751 from hashicorp/phinze/fixup-remote-exec
provisioner/remote-exec: Move script cleanup after command wait
This commit is contained in:
commit
6148229888
|
@ -176,8 +176,8 @@ func (p *ResourceProvisioner) runScripts(
|
||||||
go p.copyOutput(o, outR, outDoneCh)
|
go p.copyOutput(o, outR, outDoneCh)
|
||||||
go p.copyOutput(o, errR, errDoneCh)
|
go p.copyOutput(o, errR, errDoneCh)
|
||||||
|
|
||||||
|
remotePath := comm.ScriptPath()
|
||||||
err = retryFunc(comm.Timeout(), func() error {
|
err = retryFunc(comm.Timeout(), func() error {
|
||||||
remotePath := comm.ScriptPath()
|
|
||||||
|
|
||||||
if err := comm.UploadScript(remotePath, script); err != nil {
|
if err := comm.UploadScript(remotePath, script); err != nil {
|
||||||
return fmt.Errorf("Failed to upload script: %v", err)
|
return fmt.Errorf("Failed to upload script: %v", err)
|
||||||
|
@ -192,13 +192,6 @@ func (p *ResourceProvisioner) runScripts(
|
||||||
return fmt.Errorf("Error starting script: %v", err)
|
return fmt.Errorf("Error starting script: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload a blank follow up file in the same path to prevent residual
|
|
||||||
// script contents from remaining on remote machine
|
|
||||||
empty := bytes.NewReader([]byte(""))
|
|
||||||
if err := comm.Upload(remotePath, empty); err != nil {
|
|
||||||
return fmt.Errorf("Failed to upload empty follow up script: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -214,6 +207,14 @@ func (p *ResourceProvisioner) runScripts(
|
||||||
<-outDoneCh
|
<-outDoneCh
|
||||||
<-errDoneCh
|
<-errDoneCh
|
||||||
|
|
||||||
|
// Upload a blank follow up file in the same path to prevent residual
|
||||||
|
// script contents from remaining on remote machine
|
||||||
|
empty := bytes.NewReader([]byte(""))
|
||||||
|
if err := comm.Upload(remotePath, empty); err != nil {
|
||||||
|
// This feature is best-effort.
|
||||||
|
log.Printf("[WARN] Failed to upload empty follow up script: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// If we have an error, return it out now that we've cleaned up
|
// If we have an error, return it out now that we've cleaned up
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue