tmatilai / vagrant-proxyconf

Vagrant plugin that configures the virtual machine to use proxies
MIT License
531 stars 74 forks source link

VirtualBox guest-specific operations error #81

Closed okeefm closed 10 years ago

okeefm commented 10 years ago

Hello,

I'm using Vagrant with Vagrant-proxyconf behind a corporate proxy. When I run VAGRANT_LOG=info vagrant up --provider=docker using the "Docker" provider on a Mac (backed by VirtualBox), I get the following error:

INFO runner: Running action: #<Vagrant::Action::Builder:0x00000104b60788>
ERROR vagrant: Vagrant experienced an error! Details:
ERROR vagrant: #<Vagrant::Errors::MachineGuestNotReady: Guest-specific operations were attempted on a machine that is not
ready for guest communication. This should not happen and a bug
should be reported.>
ERROR vagrant: Guest-specific operations were attempted on a machine that is not
ready for guest communication. This should not happen and a bug
should be reported.
ERROR vagrant: /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/machine.rb:231:in `guest'
/Users/mokeefe/.vagrant.d/gems/gems/vagrant-proxyconf-1.4.0.dev/lib/vagrant-proxyconf/action/base.rb:110:in `supported?'
/Users/mokeefe/.vagrant.d/gems/gems/vagrant-proxyconf-1.4.0.dev/lib/vagrant-proxyconf/action/base.rb:19:in `call'

[middle of stack trace omitted for brevity]

/Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/machine.rb:161:in `call'
/Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/machine.rb:161:in `action'
/Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
 INFO interface: error: Guest-specific operations were attempted on a machine that is not
ready for guest communication. This should not happen and a bug
should be reported.

You can see the full error message at: https://gist.github.com/ead2bd894a1f0b0eb11b.git

I'm using the following versions of things: Mac OSX 10.9.4 Vagrant 1.6.3 vagrant-proxyconf 1.4.0.dev (installed from Git master) Docker 1.0.1

My Vagrantfiles are located at: https://gist.github.com/okeefm/91a35f5b02734f9cffd5

otahi commented 10 years ago

Hello @okeefm ,

Thank you for reporting!

I am trying to research this problem. But I do not understand what the files structure. Can you show like this?(tree command result is enough)

Vagrantfile
  ├─ docker
      ├─ Vagrantfile

Can you simplify this problem with a smallest set? If so it is easy to understand for me. (ex only one Vagrantfile with a docker image)

If Docker host is CoreOS, please use different anothre branch(see #75)

okeefm commented 10 years ago

Thank you for the prompt response! I've created a smaller Vagrantfile that is exhibiting the same issues:

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  # All Vagrant configuration is done here.

if Vagrant.has_plugin?("vagrant-proxyconf")
    config.proxy.http     = "http://gatekeeper.mitre.org:80"
    config.proxy.https    = "http://gatekeeper.mitre.org:80"
    config.proxy.no_proxy = "localhost,127.0.0.1,.mitre.org"
  end

  config.vm.define "rootBox" do |rb|
    rb.vm.box = "3scale/docker"
    rb.vm.provision "docker"
    rb.vm.provision "shell", inline:
      "ps aux | grep 'sshd:' | awk '{print $2}' | xargs kill"
  end

  config.vm.define "app" do |app|
    app.vm.provider "docker" do |d|
      d.vagrant_vagrantfile = "./Vagrantfile"
      d.vagrant_machine = "rootBox"
      d.image = "dockerfile/mongodb"
      d.name = "app_db"
      # d.expose = [27017]
      # d.remains_running = true
    end
  end

end

Vagrant is giving the same error: you can see the new stack trace at https://gist.github.com/okeefm/d6683fe98ef6d19497c3

Docker host in this case is Ubuntu 14.04 trusty, from 3scale/docker.

otahi commented 10 years ago

@okeefm Thank you for your simplification!! I reproduced this problem and I understand what occurred. Then I found the way to avoid this problem with Vagranfile separation. Can you try following solution?

Reason

Vagrant-proxyconf can not work for a docker container on a docker host(vagrant box). Because vagrant can not communicate with a docker container by same way as a docker host.

Solution

Your Vagrantfile set vagrant-proxyconf configuration for a both docker container and a docker host. So I have separate Vagrantfile each.

.
├── Vagrantfile
└── rootBox
    └── Vagrantfile

Vagrantfile

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  # All Vagrant configuration is done here.

  config.vm.define "app" do |app|
    app.vm.provider "docker" do |d|
      d.vagrant_vagrantfile = "rootBox/Vagrantfile"
      d.vagrant_machine = "rootBox"
      d.image = "ubuntu:14.04"
      d.name = "app"
    end
  end
end

rootBox/Vagrantfile

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  # All Vagrant configuration is done here.

  if Vagrant.has_plugin?("vagrant-proxyconf")
    config.proxy.http     = "http://10.0.2.2:13128"
    config.proxy.https    = "http://10.0.2.2:13128"
    config.proxy.no_proxy = "localhost,127.0.0.1,.mitre.org"
  end

  config.vm.define "rootBox" do |rb|
    rb.vm.box = "3scale/docker"
    rb.vm.provision "docker"
    rb.vm.provision "shell", inline:
      "ps aux | grep 'sshd:' | awk '{print $2}' | xargs kill"
  end
end

Result

Then result seems OK.

$ vagrant docker-run app -- 'env'
==> app: Docker host is required. One will be created if necessary...
    app: Vagrant will now create or start a local VM to act as the Docker
    app: host. You'll see the output of the `vagrant up` for this VM below.
    app:
    app: Importing base box '3scale/docker'...
    app: Matching MAC address for NAT networking...
    app: Checking if box '3scale/docker' is up to date...
    app: Setting the name of the VM: rootBox_rootBox_1409352351263_75132
    app: Fixed port collision for 4243 => 4243. Now on port 2200.
    app: Fixed port collision for 22 => 2222. Now on port 2201.
    app: Clearing any previously set network interfaces...
    app: Preparing network interfaces based on configuration...
    app: Adapter 1: nat
    app: Forwarding ports...
    app: 4243 => 2200 (adapter 1)
    app: 22 => 2201 (adapter 1)
    app: Booting VM...
    app: Waiting for machine to boot. This may take a few minutes...
    app: SSH address: 127.0.0.1:2201
    app: SSH username: vagrant
    app: SSH auth method: private key
    app: Warning: Connection timeout. Retrying...
    app: Machine booted and ready!
    app: Configuring proxy for Apt...
    app: Configuring proxy for Docker...
    app: Configuring proxy environment variables...
GuestAdditions 4.3.10 running --- OK.
    app: Checking for guest additions in VM...
    app: Mounting shared folders...
    app: /vagrant => /Users/otahi/tmp/vagrant-proxyconf-issue-81/rootBox
    app: Running provisioner: docker...
    app: Configuring Docker to autostart containers...
    app: Running provisioner: shell...
    app: Running: inline script
    app: stdin: is not a tty
==> app: Syncing folders to the host VM...
    app: Configuring proxy for Apt...
    app: Configuring proxy for Docker...
    app: Configuring proxy environment variables...
    app: Mounting shared folders...
    app: /var/lib/docker/docker_1409352384_23740 => /Users/otahi/tmp/vagrant-proxyconf-issue-81
==> app: Creating the container...
    app:   Name: app
    app:  Image: ubuntu:14.04
    app:    Cmd: env
       app: Volume: /var/lib/docker/docker_1409352384_23740:/vagrant
    app:
    app: Container is starting. Output will stream in below...
    app:
    app: Unable to find image 'ubuntu:14.04' locally
    app: Pulling repository ubuntu
    app:
    app:
    app:
    app:
    app:
    app:
    app:
    app: HOME=/
    app: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    app: HOSTNAME=187b3ad9f817
okeefm commented 10 years ago

This solution fixed it, thanks!

otahi commented 10 years ago

Excellent!:smile: Thank you.