diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a2132ea8..9fb69d5d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ BUG FIXES: - guests/ubuntu: "localhost" is preserved when changing hostnames. [GH-2383] - hosts/gentoo: Support systemd for NFS startup. [GH-2382] + - providers/virtualbox: Don't start new VM if VirtualBox has transient + failure during `up` from suspended. [GH-2479] - provisioners/salt: Bootstrap on FreeBSD systems work. [GH-2525] ## 1.3.5 (October 15, 2013) diff --git a/plugins/providers/virtualbox/driver/meta.rb b/plugins/providers/virtualbox/driver/meta.rb index 530eaefeb..4a4304668 100644 --- a/plugins/providers/virtualbox/driver/meta.rb +++ b/plugins/providers/virtualbox/driver/meta.rb @@ -63,7 +63,8 @@ module VagrantPlugins if !driver_klass supported_versions = driver_map.keys.sort.join(", ") - raise Vagrant::Errors::VirtualBoxInvalidVersion, :supported_versions => supported_versions + raise Vagrant::Errors::VirtualBoxInvalidVersion, + supported_versions: supported_versions end @logger.info("Using VirtualBox driver: #{driver_klass}") diff --git a/plugins/providers/virtualbox/driver/version_4_1.rb b/plugins/providers/virtualbox/driver/version_4_1.rb index 2854e39ba..6d56c851c 100644 --- a/plugins/providers/virtualbox/driver/version_4_1.rb +++ b/plugins/providers/virtualbox/driver/version_4_1.rb @@ -482,7 +482,23 @@ module VagrantPlugins end def vm_exists?(uuid) - raw("showvminfo", uuid).exit_code == 0 + 5.times do |i| + result = raw("showvminfo", uuid) + return true if result.exit_code == 0 + + # GH-2479: Sometimes this happens. In this case, retry. If + # we don't see this text, the VM really probably doesn't exist. + return false if !result.stderr.include?("CO_E_SERVER_EXEC_FAILURE") + + # Sleep a bit though to give VirtualBox time to fix itself + sleep 2 + end + + # If we reach this point, it means that we consistently got the + # failure, do a standard vboxmanage now. This will raise an + # exception if it fails again. + execute("showvminfo", uuid) + return true end end end diff --git a/plugins/providers/virtualbox/driver/version_4_2.rb b/plugins/providers/virtualbox/driver/version_4_2.rb index a537c4a60..75f9a664e 100644 --- a/plugins/providers/virtualbox/driver/version_4_2.rb +++ b/plugins/providers/virtualbox/driver/version_4_2.rb @@ -491,7 +491,23 @@ module VagrantPlugins end def vm_exists?(uuid) - raw("showvminfo", uuid).exit_code == 0 + 5.times do |i| + result = raw("showvminfo", uuid) + return true if result.exit_code == 0 + + # GH-2479: Sometimes this happens. In this case, retry. If + # we don't see this text, the VM really probably doesn't exist. + return false if !result.stderr.include?("CO_E_SERVER_EXEC_FAILURE") + + # Sleep a bit though to give VirtualBox time to fix itself + sleep 2 + end + + # If we reach this point, it means that we consistently got the + # failure, do a standard vboxmanage now. This will raise an + # exception if it fails again. + execute("showvminfo", uuid) + return true end end end diff --git a/plugins/providers/virtualbox/driver/version_4_3.rb b/plugins/providers/virtualbox/driver/version_4_3.rb index 123906502..306328cb5 100644 --- a/plugins/providers/virtualbox/driver/version_4_3.rb +++ b/plugins/providers/virtualbox/driver/version_4_3.rb @@ -491,7 +491,23 @@ module VagrantPlugins end def vm_exists?(uuid) - raw("showvminfo", uuid).exit_code == 0 + 5.times do |i| + result = raw("showvminfo", uuid) + return true if result.exit_code == 0 + + # GH-2479: Sometimes this happens. In this case, retry. If + # we don't see this text, the VM really probably doesn't exist. + return false if !result.stderr.include?("CO_E_SERVER_EXEC_FAILURE") + + # Sleep a bit though to give VirtualBox time to fix itself + sleep 2 + end + + # If we reach this point, it means that we consistently got the + # failure, do a standard vboxmanage now. This will raise an + # exception if it fails again. + execute("showvminfo", uuid) + return true end end end