Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
Fix for #336:
Browse files Browse the repository at this point in the history
Subprocessed being interrupted resulted in it looking
like those commands were executing successfully but with
zero output.  Interrupting the sudo prompt would result
in any command running in sudo returning nothing and looking
like it had succeeded.  There was some clean up code in
the lxc provider that nuked vagrant container state in
the .vagrant directory if it looked like the container no
longer existed based on the result of lxc-ls.  Interrupting
this check resulted in it looking like the container not
existing, resulting in the provider code nuking the lxc dir
in .vagrant.  Voila
  • Loading branch information
nicobrevin committed Dec 15, 2017
1 parent b96ba86 commit f224fc5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/vagrant-lxc/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ def initialize(message, *args)
end
end

# Raised when user interrupts a subprocess
class SubprocessInterruptError < Vagrant::Errors::VagrantError
error_key(:lxc_interrupt_error)
def initialize(message, *args)
super
end
end


class NamespacesNotSupported < Vagrant::Errors::VagrantError
end

Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-lxc/sudo_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def execute(*command, &block)
# nicely handled by Vagrant.
if r.exit_code != 0
if @interrupted
@logger.info("Exit code != 0, but interrupted. Ignoring.")
raise LXC::Errors::SubprocessInterruptError, command.inspect
else
raise LXC::Errors::ExecuteError,
command: command.inspect, stderr: r.stderr, stdout: r.stdout, exitcode: r.exit_code
Expand Down
3 changes: 3 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ en:
preparing: Setting up mount entries for shared folders...

errors:
lxc_interrupt_error: |-
Interrupted
lxc_execute_error: |-
There was an error executing %{command}
Expand Down

0 comments on commit f224fc5

Please sign in to comment.