Merge pull request #2483 from andyfowler/retryable-customize
providers/virtualbox: use Retryable for Virtualbox customize & sane_defaults actions
This commit is contained in:
commit
56eb53d8af
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -129,7 +129,7 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def execute_command(command)
|
||||
raw(*command)
|
||||
execute(*command)
|
||||
end
|
||||
|
||||
def export(path)
|
||||
|
|
|
@ -129,7 +129,7 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def execute_command(command)
|
||||
raw(*command)
|
||||
execute(*command)
|
||||
end
|
||||
|
||||
def export(path)
|
||||
|
|
|
@ -127,7 +127,7 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def execute_command(command)
|
||||
raw(*command)
|
||||
execute(*command)
|
||||
end
|
||||
|
||||
def export(path)
|
||||
|
|
|
@ -127,7 +127,7 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def execute_command(command)
|
||||
raw(*command)
|
||||
execute(*command)
|
||||
end
|
||||
|
||||
def export(path)
|
||||
|
|
Loading…
Reference in New Issue