Open me-kell opened 2 years ago
Hey there, I think this is the right behavior for Vagrant. That is, if the VM managed by Vagrant no longer exists, then Vagrant should remove it from it's index and clean up the associated files. So, I'm going to go ahead and close this issue.
The VM still exists. It has simply been unregistered from vbox via unregistervm
. Not deleted!
If we register the VM again vagrant ignores that the VM still exists. Thus vagrant up
will create a new VM. Resulting in two VMs.
Is this really the intended behavior?
Is this behavior documented?
AFAICS the documentation of vagrant status
and vagrant snapshot list
simply states that:
vagrant status This will tell you the state of the machines Vagrant is managing.
vagrant snapshot list This command will list all the snapshots taken.
But instead (in the background and without any warning) it deletes the contents of the directory.vagrant\machines\default\virtualbox
.
It is very misleading that asking the status or listing snapshots will delete data in the background without asking.
Please either document it or (better) add a message in those function that informs the user about deleting this information.
I'd suggest to reopen this issue.
Thanks for the clarification! I'm going to reopen this issue.
Looking into more the crux of the issue seems to be that Vagrant is unable to verify the machine exists. That is, Vagrant machine data dir gets cleared out since the vm gets reloaded. Part of the process checks if the vm exists. This check errors since the machine is unregistered. For example, when I ran this directly I got the error
-> % VBoxManage showvminfo 0b6f8582-2726-4795-b791-5f6ab603c81f
VBoxManage: error: Could not find a registered machine with UUID {0b6f8582-2726-4795-b791-5f6ab603c81f}
VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "FindMachine(Bstr(VMNameOrUuid).raw(), machine.asOutParam())" at line 3139 of file VBoxManageInfo.cpp
Were you able to figure out how to get away with the error? Will it affect the new vm installations?
Vagrant version
Vagrant 2.2.19
Host operating system
Guest operating system
any
Vagrantfile
any
Actual behavior
The contents of the
.vagrant\machines\default\virtualbox
are deleted if the virtual machine is not registered.Steps to reproduce
See also below under Detailed Steps to reproduce
vagrant snapshot list
or simplyvagrant status
.vagrant\machines\default\virtualbox
are deleted.References
Maybe related to (https://github.com/hashicorp/vagrant/issues/10977#issue-470214199)
Detailed Steps to reproduce