From 163e1997a67d102b060565983ab5fe515e62f3f5 Mon Sep 17 00:00:00 2001 From: "nico.vanelslande" Date: Tue, 31 May 2016 11:33:58 +0100 Subject: [PATCH] Make virtualbox vm_exists? more resilient to VirtualBox transient failures. We know that the vm does not exist if we get VBOX_E_OBJECT_NOT_FOUND. For any other error, this may well be VirtualBox getting confused and it is probably worth retrying... --- plugins/providers/virtualbox/driver/version_4_1.rb | 6 +++--- plugins/providers/virtualbox/driver/version_4_2.rb | 6 +++--- plugins/providers/virtualbox/driver/version_4_3.rb | 6 +++--- plugins/providers/virtualbox/driver/version_5_0.rb | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/plugins/providers/virtualbox/driver/version_4_1.rb b/plugins/providers/virtualbox/driver/version_4_1.rb index 3ec3c0ee9..79f4174ad 100644 --- a/plugins/providers/virtualbox/driver/version_4_1.rb +++ b/plugins/providers/virtualbox/driver/version_4_1.rb @@ -661,9 +661,9 @@ module VagrantPlugins 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") + # If vboxmanage returned VBOX_E_OBJECT_NOT_FOUND, + # then the vm truly does not exist. Any other error might be transient + return false if result.stderr.include?("VBOX_E_OBJECT_NOT_FOUND") # Sleep a bit though to give VirtualBox time to fix itself sleep 2 diff --git a/plugins/providers/virtualbox/driver/version_4_2.rb b/plugins/providers/virtualbox/driver/version_4_2.rb index a0a18d98d..a50096022 100644 --- a/plugins/providers/virtualbox/driver/version_4_2.rb +++ b/plugins/providers/virtualbox/driver/version_4_2.rb @@ -594,9 +594,9 @@ module VagrantPlugins 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") + # If vboxmanage returned VBOX_E_OBJECT_NOT_FOUND, + # then the vm truly does not exist. Any other error might be transient + return false if result.stderr.include?("VBOX_E_OBJECT_NOT_FOUND") # Sleep a bit though to give VirtualBox time to fix itself sleep 2 diff --git a/plugins/providers/virtualbox/driver/version_4_3.rb b/plugins/providers/virtualbox/driver/version_4_3.rb index 66c06f93f..a2db97d50 100644 --- a/plugins/providers/virtualbox/driver/version_4_3.rb +++ b/plugins/providers/virtualbox/driver/version_4_3.rb @@ -701,9 +701,9 @@ module VagrantPlugins 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") + # If vboxmanage returned VBOX_E_OBJECT_NOT_FOUND, + # then the vm truly does not exist. Any other error might be transient + return false if result.stderr.include?("VBOX_E_OBJECT_NOT_FOUND") # Sleep a bit though to give VirtualBox time to fix itself sleep 2 diff --git a/plugins/providers/virtualbox/driver/version_5_0.rb b/plugins/providers/virtualbox/driver/version_5_0.rb index 961f5ad55..f8a49eb51 100644 --- a/plugins/providers/virtualbox/driver/version_5_0.rb +++ b/plugins/providers/virtualbox/driver/version_5_0.rb @@ -702,9 +702,9 @@ module VagrantPlugins 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") + # If vboxmanage returned VBOX_E_OBJECT_NOT_FOUND, + # then the vm truly does not exist. Any other error might be transient + return false if result.stderr.include?("VBOX_E_OBJECT_NOT_FOUND") # Sleep a bit though to give VirtualBox time to fix itself sleep 2