Commit 6ec428cc authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

provisioner/shell: retry file delete [GH-2286]

parent f41429b6
...@@ -270,7 +270,10 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error { ...@@ -270,7 +270,10 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
return fmt.Errorf("Script exited with non-zero exit status: %d", cmd.ExitStatus) return fmt.Errorf("Script exited with non-zero exit status: %d", cmd.ExitStatus)
} }
// Delete the temporary file we created // Delete the temporary file we created. We retry this a few times
// since if the above rebooted we have to wait until the reboot
// completes.
err = p.retryable(func() error {
cmd = &packer.RemoteCmd{ cmd = &packer.RemoteCmd{
Command: fmt.Sprintf("rm -f %s", p.config.RemotePath), Command: fmt.Sprintf("rm -f %s", p.config.RemotePath),
} }
...@@ -280,6 +283,12 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error { ...@@ -280,6 +283,12 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
p.config.RemotePath, err) p.config.RemotePath, err)
} }
cmd.Wait() cmd.Wait()
return nil
})
if err != nil {
return err
}
if cmd.ExitStatus != 0 { if cmd.ExitStatus != 0 {
return fmt.Errorf( return fmt.Errorf(
"Error removing temporary script at %s!", "Error removing temporary script at %s!",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment