New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vagrant destroy kills too many interfaces #1324
Comments
You're correct. I detect unused network interfaces by inspecting all VMs that VirtualBox knows about. This does not include (rightfully) other user's virtual machines. Do you have an idea of how to better do this check? I'm investigating but nothing jumps out to me yet. |
As you can't see other users VMs with "VBoxManage list " it seems that the solution is going to be hard to find. I see 2 options :
|
How about you record in the file which ones vagrant created via comments in On Wed, Jan 30, 2013 at 3:07 AM, Nicolas Szalay notifications@github.comwrote:
|
It was an option we talked about with my colleagues, but if the interface gets reused by vbox for another user he will be stuck. |
Tough challenge..... i looked through all modifyvm parameters but found none to be suited for the cause. |
I'm actually running into this same challenge with the VMware Fusion provider that I have been working on. Fusion provides no central way to do this same thing. With Fusion I decided to just punt on the issue and just put up a "known issues" page that covers this limitation. Perhaps I should just do the same with VirtualBox. |
Coming back to this finally. So, the VMware provider, used by thousands of people, doesn't clean up network interfaces. It never has. And nobody has complained. Maybe the solution to this is to just actually disable that code path... |
Agreed 👍 |
Here's how I patched my Vagrantfile to disable this behaviour on Virtualbox: [VagrantPlugins::ProviderVirtualBox::Driver::Version_4_1, VagrantPlugins::ProviderVirtualBox::Driver::Version_4_2].each do |cls|
cls.class_eval do
def delete_unused_host_only_networks
puts "delete_unused_host_only_networks discarded"
end
end
end |
Vagrant no longer removes unused network interfaces and leaves it up to the user. This can forcibly be re-enabled using VirtualBox provider-specific config: config.vm.provider "virtualbox" do |v|
v.destroy_unused_network_interfaces = true
end |
cool stuff - that was always annoying on windows... 👍 |
I think this is being handled wrong still for private networks. If no IP is specified vagrant should first attempt to match the guest static IP to any existing host-only adapters before generating a new one, otherwise multiple adapters end up being generated, at a minimum there should be an option for this. It should also have the ability to disable/reconfigure dhcp for that network if needed as opposed to just generating more adapters. Generating more than 1 host-only adapter should really be a last resort used if its impossible to use/reconfigure existing ones. |
I have noticed that Vagrant may not remove "vboxnet0" anymore, but it does shut down the interface, and remove its IP making it useless still ;-( |
When working on a multi users environment, each with its vagrant setup (and vboxnet interface, for network isolation, routing) vagrant kills too many interfaces on destroy
sample ifconfig output before:
then "vagrant destroy aVM"
sample output after :
and if the user with VMs linked to vboxnet2 destroys a VM, then vboxneti0 and vboxnet1 get destroyed. The vms do not get killed or harmed, but they lose the network.
Each VM has 2 interfaces, 1st one is using vbox DHCP, and the second one is a hostonly one (used in routing)
sample VagrantFile entry
My guess is that the code in the function "delete_unused_host_only_networks" (plugins/providers/virtualbox/driver/version_4_2.rb:67) is not aware of the multi users aspect of the usage, then kills interfaces that seem unused to it.
additionnal informations :
The text was updated successfully, but these errors were encountered: