Gitlab runner does not seem to start cloned virtualbox vm

Hi all,

Been trying to setup a runner on windows 10 with virtualbox ubuntu vm as executor.

Unfortunately it does not work most of the time, and I am constantly getting this error:

ERROR: Preparation failed: VBoxManageOutput error: vboxmanage.exe: error: The VM session was closed before any attempt to power it on

vboxmanage.exe: error: Details: code E_FAIL (0x80004005), component SessionMachine, interface ISession

Online research suggested to discard saved vm state, but I have none. I actually have disable_snapshots set to true in config.toml

Every time I kick start a CI job on gitlab web interface, I was able to see a clone being created in VirtualBox Manager window. However I see that the clone vm remains in “powered off” state until eventually gitlab runner complains that the session was closed before any attempt made to boot the vm.

For clarification, gitlab runner is started as a service by nt authority\system account.
The vm was also created with the same account.

At this point I am not sure if Gitlab runner did not issue the command to boot the vm or there was something wrong with the vm in virtualbox.

Any suggestion to troubleshooting is appreciated.


I seem to have found the root cause of my problem.

After a successful CI job runs, I still have 3 VBoxHeadless.exe process left running.
If I kill those and all other processes related to virtualbox, then the next CI job will run fine.

I guess the question becomes is it that the gitlab runner never properly cleans up after a CI job or is it that virtualbox never properly cleans up after itself.

Also experiencing this issue (tried both disable_snapshots true and false). Indeed killing the VBoxHeadless processes in task manager allows the next job to run, but then the one after fails again, although sometimes it’s intermittent.

Were you able to find a more permanent solution yet?

Some other notes:

  • The gitlab-runner service is running as a local gitlab user which is also able to use VirtualBox.
  • Even for the successful job, VBoxSVC.log contains lots of COM ERRORs like below - might be a red herring though:
ERROR [COM]: aRC=VBOX_E_OBJECT_NOT_FOUND (0x80bb0001) aIID={XXXXXXXXXXUUIDXXXXXXXX} aComponent={VirtualBoxWrap} aText={Could not find a registered machine named 'ubuntu-20-04-runner-XXXXXXXX-concurrent-0'}, preserve=false aResultDetail=0
ERROR [COM]: aRC=VBOX_E_OBJECT_NOT_FOUND (0x80bb0001) aIID={YYYYYYYYUUIDYYYYYYYYYYY} aComponent={SessionMachine} aText={No storage device attached to device slot 1 on port 1 of controller 'IDE'}, preserve=false aResultDetail=0

This is due to a bug in Virtualbox : #20574 (VBoxManage 'start --type headless' cannot be correctly closed by 'controlvm acpipowerbutton') – Oracle VM VirtualBox

Updated to 6.1.28 as suggested by VBoxManage.exe: STDERR: There was an error while executing `VBoxManage`, a CLI used by Vagrant · Issue #12484 · hashicorp/vagrant · GitHub
and it worked.