hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.28k stars 4.44k forks source link

Windows 10 guest machine enters invalid state intermittently #9023

Open jhakonen opened 7 years ago

jhakonen commented 7 years ago

Vagrant version

vagrant -v
Vagrant 2.0.0

Host operating system

Windows 10 pro x64

Guest operating system

Windows 10 pro x64

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

require 'etc'

# Adjust this to match your environment
WOTPATH = "C:\\Games\\World_of_Tanks"

Vagrant.configure("2") do |config|
    config.vm.box = "jhakonen/windows-10-n-pro-en-x86_64"
    config.vm.guest = :windows
    config.vm.communicator = "winrm"
    config.vm.synced_folder WOTPATH, "/world_of_tanks"
    config.vm.provision "shell" do |s|
        s.path = "vagrant-bootstrap.ps1"
        s.args = "-FromVagrant"
    end
    config.vm.provision :reload

    config.vm.provider "virtualbox" do |vb|
        vb.cpus = Etc.nprocessors
    end

    # from https://support.teamspeakusa.com/index.php?/Knowledgebase/Article/View/44/16/which-ports-does-the-teamspeak-3-server-use
    config.vm.network :forwarded_port, guest: 9987, host: 9987, id: "ts-server-voice", protocol: "udp"
    config.vm.network :forwarded_port, guest: 10011, host: 10011, id: "ts-server-serverquery", protocol: "tcp"
    config.vm.network :forwarded_port, guest: 30033, host: 30033, id: "ts-server-filetransfer", protocol: "tcp"
    config.vm.network :forwarded_port, guest: 41144, host: 41144, id: "ts-server-tsdns", protocol: "tcp"
end

Also here: https://github.com/jhakonen/wot-teamspeak-mod/blob/master/Vagrantfile

Debug output

https://www.dropbox.com/s/624gk2v422nplqs/output.log?dl=1

Expected behavior

Vagrant should have noticed that machine booted up ok.

Actual behavior

It did not, it gave error:

The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'unknown' state. Please verify everything is configured
properly and try again.

If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.

The primary issue for this error is that the provider you're using
is not properly configured. This is very rarely a Vagrant issue.

I'm getting intermittently this error. The machine boots up nicely, but vagrant sometimes gives this error, and sometimes it does not. In VirtualBox GUI, the guest machine shows up running fine.

vagrant up --debug didn't help much, so I added some extra output (see https://www.dropbox.com/s/vrnr18752behpwf/logging.diff?dl=1 ).

Starting from scratch, with previous machine destroyed: vagrant up --debug 2>&1 | Tee-Object -file c:\temp\output.log

Search the debug output for string read_state. State is running on line 11176, nil on line 11190, and running again on line 11696.

It looks like showvminfo <uuid> --machinereadable command exits with 0 exit code, and has empty stdout and stderr (log line 11188). Which read_state() in Version_5_0 class can't parse and returns nil. Command executions both before and after the failed execution show that the machine info was returned just fine.

Steps to reproduce

  1. vagrant destroy -f
  2. vagrant up
  3. ... Keep repeating until error occurs.
briancain commented 7 years ago

Hi @jhakonen - have you seen this behavior if you use a different vagrant box? Thanks!

jhakonen commented 7 years ago

I tried with Centos 7 guest, on same host (Windows 10 x64 pro). Took more repeated up/destroys, but got the same error message:

vagrant destroy -f; vagrant up
==> wotsources: VM not created. Moving on...
Bringing machine 'wotsources' up with 'virtualbox' provider...
==> wotsources: Importing base box 'centos/7'...
==> wotsources: Matching MAC address for NAT networking...
==> wotsources: Checking if box 'centos/7' is up to date...
==> wotsources: Setting the name of the VM: tools_wotsources_1507059705933_44968
==> wotsources: Clearing any previously set network interfaces...
==> wotsources: Preparing network interfaces based on configuration...
    wotsources: Adapter 1: nat
==> wotsources: Forwarding ports...
    wotsources: 22 (guest) => 2222 (host) (adapter 1)
==> wotsources: Running 'pre-boot' VM customizations...
==> wotsources: Booting VM...
==> wotsources: Waiting for machine to boot. This may take a few minutes...
    wotsources: SSH address: 127.0.0.1:2222
    wotsources: SSH username: vagrant
    wotsources: SSH auth method: private key
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'unknown' state. Please verify everything is configured
properly and try again.

If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.

The primary issue for this error is that the provider you're using
is not properly configured. This is very rarely a Vagrant issue.

Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

require 'etc'

WOTPATH = ENV["WOTPATH"]
OUTPATH = ENV["OUTPATH"]
CPU_COUNT = Etc.nprocessors
MEMORY = 4 * 1024 # In Megabytes

def install_plugins(plugins)
  not_installed = []
  plugins.each do |plugin|
    unless Vagrant.has_plugin?(plugin)
      not_installed << plugin
    end
  end

  unless not_installed.empty?
    puts "The following required plugins must be installed:"
    puts "'#{not_installed.join("', '")}'"
    print "Install? [y]/n: "
    unless STDIN.gets.chomp == "n"
      not_installed.each { |plugin| install_plugin(plugin) }
    else
      exit
    end
    $? ? continue : ( raise 'Plugin installation failed, see errors above.' )
  end
end

def install_plugin(plugin)
  system("vagrant plugin install #{plugin}")
end

# If plugins successfully installed, restart vagrant to detect changes.
def continue
  exec("vagrant #{ARGV[0]}")
end

required_plugins = ["vagrant-vbguest"]
install_plugins(required_plugins)

Vagrant.configure("2") do |config|
  config.vm.define :wotsources
  config.vm.box = "centos/7"
  config.vm.synced_folder WOTPATH, "/world_of_tanks"
  config.vm.synced_folder OUTPATH, "/extracts"
  config.vm.synced_folder ".", "/vagrant", type: "virtualbox"

  config.vbguest.auto_update = true
  config.vbguest.auto_reboot = true

  config.vm.provider "virtualbox" do |vb|
    vb.memory = MEMORY
    vb.cpus = Etc.nprocessors
  end

  config.vm.provision "ansible_local" do |ansible|
    ansible.playbook = "playbook.yml"
  end
end
devilstars commented 6 years ago

Same here with default Homestead (laravel) vagrant box (https://github.com/laravel/homestead). At least once a day when I do vagrant halt and vagrant up i have the same error.

netdelight commented 6 years ago

Same here with Homestead and other custom boxes...

virgo47 commented 6 years ago

The same here, various Linux boxes (not using other anyway), sometimes just repeating vagrant up is enough. It gladly happens when I want to show someone how it all works with a single command. :-)

Bilal898 commented 5 years ago

vagrant reload

Rutman commented 3 years ago

Virtualbox ver 6.1.18.r... and virtualization Windows 10
if processor intel run command as administrator in cmd dism.exe /Online /Enable-Feature:Microsoft-Hyper-V-All Reboot

ribeirobreno commented 3 years ago

I've just tried the solution from @Rutman to enable Hyper-V and has been working well for me with Virtualbox 6.1.22

pedrofurtado commented 3 years ago

Same error here.

Vagrant 2.2.16 Virtualbox 6.1.22 Box: centos/8

When I execute vagrant up, sometimes the machine boots and connect ssh, sometimes don't. Really strange 🤔

If I downgrade the vagrant version, to 2.2.10 for example, the error disappears. Maybe can be related to some change in versions between 2.2.10 and 2.2.16 🤝