Unplanned host reboot causes vagrant to lose all virtualbox guest associations

156 views
Skip to first unread message

Charlie

unread,
Dec 4, 2017, 5:34:19 PM12/4/17
to Vagrant
Hi group,

Is it expected behaviour that vagrant loses all it's associations to virtualbox guests if the host machine is rebooted without running vagrant halt/suspend first on the guests first (e.g. due to power loss or a system update)?

I see this every time a Windows host running Vagrant 2.0.1 and Virtualbox 5.1.30 r118389 reboots for e.g. an unattended windows update (and it's been happening with every version of vagrant and virtualbox I've used prior to the current ones).

Is there anything that can be done to get vagrant not to lose track of guests after such a host reboot? Re-creating and re-provisioning them is quite tedious (even with the aid of ansible).

Thanks,
Charlie

Alvaro Miranda Aguilera

unread,
Dec 5, 2017, 2:33:09 AM12/5/17
to vagra...@googlegroups.com
hello

the state of the VM is stored in the running directory of the project.

where the Vagrantfile is, a directory .vagrant is created

some of that state is pointed also to your home/.vagrant.d

When your machine starts, does anything gets deleted?

I have a Win10 machine and i don't lose any VM that is registered.

Alvaro.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/700b6dca-b73a-4cb8-8c4c-fb9853fd7361%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Charlie

unread,
Dec 5, 2017, 11:32:47 AM12/5/17
to Vagrant
Hi Alvaro

After simulating an unplanned host reboot (i.e. forcibly turning the laptop off and then on), this is what happens:

1. The machine dirs and files under ".vagrant/machines" (in the directory where the Vagrant file is) remain as they were
2. Running `vagrant global-status` shows the machines (although I think this is cached info as the warning message suggests)
3. Running `vagrant status` lists all the machines but their status is marked as "not created"
4. After running `vagrant status`, all the files in the machine dirs (under ".vagrant/machines/machine_name/vagrant" in the project directory with the Vagrant file) disappear
5. Running `VBoxManage list vms` no longer shows the machines
6. Despite this, the virtualbox files and vmdks for each machine all still exist under C:\Users\Charlie\VirtualBox VMs
7. Running `vagrant up` re-creates all the machines and re-provisions them (effectively duplicating the virtualbox machine files and vmdks that were already present in C:\Users\Charlie\VirtualBox VMs)

It's not clear to me if the issue is with vagrant losing the associations after a reboot or with Virtualbox losing track of the VMs after a reboot and causing vagrant to assume they don't exist. If the latter, I don't understand why virtualbox doesn't also lose track of other non-vagrant VMs I have created. They continue to exist and work as normal after a reboot.

Charlie


On Tuesday, December 5, 2017 at 7:33:09 AM UTC, Alvaro Miranda Aguilera wrote:
hello

the state of the VM is stored in the running directory of the project.

where the Vagrantfile is, a directory .vagrant is created

some of that state is pointed also to your home/.vagrant.d

When your machine starts, does anything gets deleted?

I have a Win10 machine and i don't lose any VM that is registered.

Alvaro.
On Mon, Dec 4, 2017 at 11:34 PM, Charlie <charlie...@gmail.com> wrote:
Hi group,

Is it expected behaviour that vagrant loses all it's associations to virtualbox guests if the host machine is rebooted without running vagrant halt/suspend first on the guests first (e.g. due to power loss or a system update)?

I see this every time a Windows host running Vagrant 2.0.1 and Virtualbox 5.1.30 r118389 reboots for e.g. an unattended windows update (and it's been happening with every version of vagrant and virtualbox I've used prior to the current ones).

Is there anything that can be done to get vagrant not to lose track of guests after such a host reboot? Re-creating and re-provisioning them is quite tedious (even with the aid of ansible).

Thanks,
Charlie

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro

Alvaro Miranda Aguilera

unread,
Dec 5, 2017, 12:04:20 PM12/5/17
to vagra...@googlegroups.com
to try to repro this.

you have multiple vagrant projects that were provisioned
you did cut the power
started, the machins gone.

what host OS?

Alvaro.

To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/264b82e7-ba18-47c8-965f-95d362b28b55%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Charlie

unread,
Dec 5, 2017, 5:29:00 PM12/5/17
to Vagrant
Host is Windows 10

I have one vagrant file that defines 4 guests (all ubuntu 16.04 LTS).

Cutting the power causes either virtualbox or vagarant (not sure which) to lose these guests even though the vmdk etc files remain on disk.

As mentioned before, I also have three manually created virtualbox guest machines (unrelated to the project or vagrant) and they survive unplanned reboots without issue.



--
Alvaro

Robert Lilly

unread,
Dec 6, 2017, 10:53:05 AM12/6/17
to Vagrant
Charlie, just for clarification, were the non-Vagrant Virtualbox VMs running at the time of the power down / reboot as well as the the Vagrant ones?

I have experienced this problem before on Windows 7 and 10, as well as OS X / MacOS. I didn't take the time to troubleshoot, I just made a habit of not leaving any VMs running when I was finished for the day.

Charlie

unread,
Dec 7, 2017, 7:50:07 PM12/7/17
to Vagrant
Alvaro, Robert:

I think I've tracked down the culprit. The non-vagrant virtualboxes were running at the time of the power down/reboot and survived with no problem - digging further in to this is what revealed the issue:

I start all my vagrant machines with a command line emulator called Cmder and rarely pay attention to the VirtualBox Manager GUI.

While doing some more debugging today I noticed that my non-vagrants were always present in the VirtualBox Manager GUI but the vagrant machines only sporadically showed up (and always showed as being powered off, even if running).

I remembered I had set the Cmder emulator to run as administrator (for an unrelated reason, nothing to do with vagrant or this issue). As soon as I ran the emulator with normal privs and issued `vagrant up` the vagrant machines started surviving reboots with no issue.

So I guess virtualbox and/or vagrant don't like communicating with each other if running under different user contexts. I don't think that's a bug (more like an implementation limitation/constraint) so, for me at least, the issue is marked 'solved' :)

Charlie

Robert Lilly

unread,
Dec 7, 2017, 8:39:24 PM12/7/17
to vagra...@googlegroups.com
Charlie,

Thank you for the follow-up. That explanation makes a lot of sense. ~R

Robert

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to a topic in the Google Groups "Vagrant" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vagrant-up/Gn0BxZh6Peg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/831f9c40-ba2a-4de3-9555-88eba86e51e6%40googlegroups.com.

Alvaro Miranda Aguilera

unread,
Dec 8, 2017, 4:51:27 AM12/8/17
to vagra...@googlegroups.com
hello

if you run the vagrant command as administrator, maybe all those lost vms are under the admin user

vagrant by default will create VMs on the default dir for each user.

Virtualbox uses   USER/VirtualBox VMs

C:\Users\Administrator\VirtualBox VMs

or maybe you can use that cmder thing to run Virtualbox and check the gui under admin.

Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/831f9c40-ba2a-4de3-9555-88eba86e51e6%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Charlie

unread,
Dec 8, 2017, 9:46:47 AM12/8/17
to Vagrant
Hi Alvaro

The on-disk location of the vmdk files never changed. It just seems that the VirtualBox Manager GUI sometimes can't see them if `vagrant up` was issued from an elevated command prompt (which in turn causes vagrant to lose them after a reboot). If I run the VirtualBox Manager GUI with admin rights, the vagrant machines show up (and the powered off/running status is correct). If I run the VirtualBox Manager GUI with normal user privs, the vagrant machines (created vwith an elevated command prompt) sometimes show up (but always listed as "powered off") or simply don't appear in the VirtualBox Manager GUI.

If I issue `vagrant up` from an non-elevated command prompt and run VirtualBox Manager GUI with normal privs too, everything works as intended. The vagrant machines are correctly listed in the GUI (with correct powered off/running status) and they survive an unplanned host reboot.

Charlie
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages