fgrehm/vagrant-lxc

varagant destroy failes because lxc-stop return 2 (already stopped)

Closed this issue · 2 comments

If the user executs "vagrant destroy", a gracefull shutdown of the LXC container is performed.

This leads to:

 INFO subprocess: Starting process: ["/usr/bin/sudo", "/usr/bin/env", "lxc-attach", "--name", "jenkins.vagrant.local", "--", "/bin/true"]
....
 INFO subprocess: Starting process: ["/usr/bin/sudo", "/usr/bin/env", "lxc-attach", "--name", "jenkins.vagrant.local", "--", "/sbin/halt"]
...
 INFO subprocess: Starting process: ["/usr/bin/sudo", "/usr/bin/env", "lxc-stop", "--name", "jenkins.vagrant.local"]
  INFO subprocess: Command not in installer, restoring original environment...
DEBUG subprocess: Selecting on IO
DEBUG subprocess: stderr: jenkins.vagrant.local is not running
DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000
DEBUG subprocess: Exit status: 2
ERROR warden: Error occurred: There was an error executing ["sudo", "/usr/bin/env", "lxc-stop", "--name", "jenkins.vagrant.local"]

The man page states:

EXIT VALUE
       0      The container was successfully stopped.

       1      An error occurred while stopping the container.

       2      The specified container exists but was not running.

So a return code of "2" is fully ok.

A modification of the "shutdown" code needs to be done.

ccope commented

Edit: Moved comment to PR.

ccope commented

Dupe of #405