Skip to content
This repository has been archived by the owner on Jul 6, 2018. It is now read-only.

Connection refused - Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, giving up #69

Open
danielfrey opened this issue Oct 27, 2015 · 6 comments

Comments

@danielfrey
Copy link

I'm having problems provisioning an image using docker on OSX (boot2docker) with chef in local mode.
My container tries to find the chef-server on the docker host instead on my OSX machine.

Is there a way I can give the container a hint so it uses the local chef or is my setup using boot2docker that makes the whole szenario impossible?

Actually I'm using the successor of boot2docker on OSX called Docker Machine. But I guess it's behaviour is the same as boot2docker and should't make a difference.

I use the following setup:

Recipe I am using

docker_ubuntu_image.rb

require 'chef/provisioning/docker_driver'

machine 'daniel' do
    recipe 'openssh::default'
    machine_options :docker_options => {
      :base_image => {
          :name => 'ubuntu',
          :repository => 'ubuntu',
          :tag => '14.04'
      },
      :command => '/usr/sbin/sshd -p 8022 -D',
    }
end

Gemfile for the setup

( still using librarian instead of berkshelf ...)

source 'https://rubygems.org'

gem 'chef-zero'
gem 'chef-provisioning-docker'
gem 'librarian-chef'

Command I executed

CHEF_DRIVER=docker chef-client -z docker_ubuntu_image.rb

Full Exception

Here the part of the exception which seems relevant to me.
172.17.42.1 is the IP the docker host is bound to.

Running handlers:
[2015-10-27T08:49:20+01:00] ERROR: Running exception handlers
Running handlers complete
[2015-10-27T08:49:20+01:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 35 seconds
[2015-10-27T08:49:20+01:00] FATAL: Stacktrace dumped to /Users/daniel/.chef/local-mode-cache/cache/chef-stacktrace.out
[2015-10-27T08:49:20+01:00] ERROR: machine[daniel] (@recipe_files::/Users/daniel/development/chef/versuch2/docker_ubuntu_image.rb line 3) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of docker run --name daniel b11c4326c0cfd6b330d290056ce4d926cc95de1c2654a9f1eb884c151f7edb0b chef-client -l auto ----
STDOUT: [2015-10-27T07:48:54+00:00] INFO: Forking chef instance to converge...
[2015-10-27T07:48:54+00:00] INFO: *** Chef 12.5.1 ***
[2015-10-27T07:48:54+00:00] INFO: Chef-client pid: 10
[2015-10-27T07:48:55+00:00] ERROR: Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, retry 1/5
[2015-10-27T07:49:00+00:00] ERROR: Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, retry 2/5
[2015-10-27T07:49:05+00:00] ERROR: Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, retry 3/5
[2015-10-27T07:49:10+00:00] ERROR: Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, retry 4/5
[2015-10-27T07:49:15+00:00] ERROR: Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, retry 5/5

================================================================================
Chef encountered an error attempting to load the node data for "daniel"
================================================================================

Networking Error:
-----------------
Connection refused - Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, giving up

Your chef_server_url may be misconfigured, or the network could be down.

Relevant Config Settings:
-------------------------
chef_server_url  "http://172.17.42.1:8889"

[2015-10-27T07:49:20+00:00] ERROR: Running exception handlers
[2015-10-27T07:49:20+00:00] ERROR: Exception handlers complete
[2015-10-27T07:49:20+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-10-27T07:49:20+00:00] ERROR: Connection refused - Connection refused connecting to http://172.17.42.1:8889/nodes/daniel, giving up
[2015-10-27T07:49:20+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
STDERR:
---- End output of docker run --name daniel b11c4326c0cfd6b330d290056ce4d926cc95de1c2654a9f1eb884c151f7edb0b chef-client -l auto ----
Ran docker run --name daniel b11c4326c0cfd6b330d290056ce4d926cc95de1c2654a9f1eb884c151f7edb0b chef-client -l auto returned 1
[2015-10-27T08:49:21+01:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
@samifruit514
Copy link

+1

1 similar comment
@kreba
Copy link

kreba commented Nov 2, 2015

+1

@marc-
Copy link
Contributor

marc- commented Nov 4, 2015

Can you try to explicitly set chef-server as workaround:

convergence_options: {
    chef_server: "http://<you_macos_addr>:8889/"
}

Make sure your chef-zero is listening on 0.0.0.0 .
Unfortunately, I don't use boot2docker, but it looks like something could be wrong with transport . Hope this will help to dig into issue.

@hrak
Copy link

hrak commented Nov 4, 2015

I also ran into this issue, and my guess is this: The mechanism used to detect boot2docker (which is now Docker Toolbox) is incompatible with Docker Toolbox.

With boot2docker the VirtualBox VM used to be called 'boot2docker', and the function using_boot2docker? searches the process list for /.*--comment boot2docker.*/.

Since Docker Toolbox the VM is now called 'default' by default, which breaks the current detection mechanism.

UPDATE: i tested by editing docker_transport.rb and changed /.*--comment boot2docker.*/ to /.*--comment default.*/. That fixed the problem but resulted in a different issue (it got the IPv6 link-local address of the interface, which resulted in an error). I fixed that by using getaddrinfo with address family AF_INET instead of IPSocket.getaddress(Socket.gethostname).

@danielfrey
Copy link
Author

That was it!
Thanks a lot! Changing to /.*--comment default.*/ makes Docker Toolbox run the recipes.

@nascimento
Copy link

#73

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

6 participants