diff --git a/plugins/providers/virtualbox/action/customize.rb b/plugins/providers/virtualbox/action/customize.rb index 0bcb84a6d..f2bfda255 100644 --- a/plugins/providers/virtualbox/action/customize.rb +++ b/plugins/providers/virtualbox/action/customize.rb @@ -25,11 +25,12 @@ module VagrantPlugins arg.to_s end - result = env[:machine].provider.driver.execute_command(processed_command) - if result.exit_code != 0 + begin + env[:machine].provider.driver.execute_command(processed_command + [:retryable => true]) + rescue Vagrant::Errors::VBoxManageError => e raise Vagrant::Errors::VMCustomizationFailed, { - :command => processed_command.inspect, - :error => result.stderr + :command => command, + :error => e.inspect } end end diff --git a/plugins/providers/virtualbox/action/sane_defaults.rb b/plugins/providers/virtualbox/action/sane_defaults.rb index fc3f66ead..1dcac0a74 100644 --- a/plugins/providers/virtualbox/action/sane_defaults.rb +++ b/plugins/providers/virtualbox/action/sane_defaults.rb @@ -55,11 +55,19 @@ module VagrantPlugins # the given string to the log, and also includes the exit status in # the log message. # + # We assume every command is idempotent and pass along the `retryable` + # flag. This is because VBoxManage is janky about running simultaneously + # on the same box, and if we up multiple boxes at the same time, a bunch + # of modifyvm commands get fired + # # @param [Array] command Command to run # @param [String] log Log message to write. def attempt_and_log(command, log) - result = @env[:machine].provider.driver.execute_command(command) - @logger.info("#{log} (exit status = #{result.exit_code})") + begin + @env[:machine].provider.driver.execute_command(command + [:retryable => true]) + rescue Vagrant::Errors::VBoxManageError => e + @logger.info("#{log} (error = #{e.inspect})") + end end # This uses some heuristics to determine if the NAT DNS proxy should diff --git a/plugins/providers/virtualbox/driver/base.rb b/plugins/providers/virtualbox/driver/base.rb index d06898b2d..1e0795739 100644 --- a/plugins/providers/virtualbox/driver/base.rb +++ b/plugins/providers/virtualbox/driver/base.rb @@ -108,6 +108,11 @@ module VagrantPlugins # Execute a raw command straight through to VBoxManage. # + # Accepts a :retryable => true option if the command should be retried + # upon failure. + # + # Raises a VBoxManage error if it fails. + # # @param [Array] command Command to execute. def execute_command(command) end diff --git a/plugins/providers/virtualbox/driver/version_4_0.rb b/plugins/providers/virtualbox/driver/version_4_0.rb index 9341a0362..e0ce73cac 100644 --- a/plugins/providers/virtualbox/driver/version_4_0.rb +++ b/plugins/providers/virtualbox/driver/version_4_0.rb @@ -129,7 +129,7 @@ module VagrantPlugins end def execute_command(command) - raw(*command) + execute(*command) end def export(path) diff --git a/plugins/providers/virtualbox/driver/version_4_1.rb b/plugins/providers/virtualbox/driver/version_4_1.rb index 6d56c851c..1f80965d2 100644 --- a/plugins/providers/virtualbox/driver/version_4_1.rb +++ b/plugins/providers/virtualbox/driver/version_4_1.rb @@ -129,7 +129,7 @@ module VagrantPlugins end def execute_command(command) - raw(*command) + execute(*command) end def export(path) diff --git a/plugins/providers/virtualbox/driver/version_4_2.rb b/plugins/providers/virtualbox/driver/version_4_2.rb index 75f9a664e..d9d3f86f1 100644 --- a/plugins/providers/virtualbox/driver/version_4_2.rb +++ b/plugins/providers/virtualbox/driver/version_4_2.rb @@ -127,7 +127,7 @@ module VagrantPlugins end def execute_command(command) - raw(*command) + execute(*command) end def export(path) diff --git a/plugins/providers/virtualbox/driver/version_4_3.rb b/plugins/providers/virtualbox/driver/version_4_3.rb index 306328cb5..5685c0ada 100644 --- a/plugins/providers/virtualbox/driver/version_4_3.rb +++ b/plugins/providers/virtualbox/driver/version_4_3.rb @@ -127,7 +127,7 @@ module VagrantPlugins end def execute_command(command) - raw(*command) + execute(*command) end def export(path)