@@ -14,6 +14,10 @@ import (
1414 "github.com/docker/machine/libmachine/log"
1515)
1616
17+ const (
18+ retryCountOnObjectNotReadyError = 5
19+ )
20+
1721var (
1822 reColonLine = regexp .MustCompile (`(.+):\s+(.*)` )
1923 reEqualLine = regexp .MustCompile (`(.+)=(.*)` )
@@ -49,6 +53,10 @@ func (v *VBoxCmdManager) vbmOut(args ...string) (string, error) {
4953}
5054
5155func (v * VBoxCmdManager ) vbmOutErr (args ... string ) (string , string , error ) {
56+ return v .vbmOutErrRetry (retryCountOnObjectNotReadyError , args ... )
57+ }
58+
59+ func (v * VBoxCmdManager ) vbmOutErrRetry (retry int , args ... string ) (string , string , error ) {
5260 cmd := exec .Command (vboxManageCmd , args ... )
5361 log .Debugf ("COMMAND: %v %v" , vboxManageCmd , strings .Join (args , " " ))
5462 var stdout bytes.Buffer
@@ -68,6 +76,13 @@ func (v *VBoxCmdManager) vbmOutErr(args ...string) (string, string, error) {
6876 }
6977 }
7078
79+ // Sometimes, we just need to retry...
80+ if retry > 0 {
81+ if strings .Contains (stderrStr , "error: The object is not ready" ) {
82+ return v .vbmOutErrRetry (retry - 1 , args ... )
83+ }
84+ }
85+
7186 if err == nil || strings .HasPrefix (err .Error (), "exit status " ) {
7287 // VBoxManage will sometimes not set the return code, but has a fatal error
7388 // such as VBoxManage.exe: error: VT-x is not available. (VERR_VMX_NO_VMX)
0 commit comments