1

We are trying to run a knife solo cook command on remote machines. When we execute the command on each machine sequentially, it works without hiccups. We tried to parallelize this by using the Parallel gem like this:

Parallel.each(machines, in_threads => machines.size) do |machine|
   knife solo cook machine.user + ":" + machine.ip <options>
end

Doing this, the thread that happens to run first executes as expected. However, the other threads do not execute and stop with the error: "EADDRINUSE: Address already in use - bind(2) for 127.0.0.1:8889"

We put in a netstat command at the same place where we call knife solo cook to investigate and found that a Listen socket has been opened on port 8889 by the first thread. We did open any socket, nor have we found any indication that knife or Net:SSH (which is used by knife) are doing this.

Does anyone know who is opening up this socket? Or whether there is any config file for it?

Thanks!

Edit: Forgot to mention, we are doing the same for knife solo prepare before calling cook and that works great. Also, the remote machines all have chef solo set up properly.

Community
  • 1
  • 1
Parimal
  • 316
  • 1
  • 6

2 Answers2

1

I googled knife chef 8889, and found this: http://docs.opscode.com/config_rb_knife.html

Looks like chef-zero is starting, and maybe chef_zero[:enabled] false would be a good thing to try in your configuration file?

Nick Veys
  • 23,458
  • 4
  • 47
  • 64
  • Yes, that is what we tried too. But it produces the same error. You are right about chef_zero though, we tried changing chef_zero[:port] to 4000 and the error message shows 4000. Now, we are trying to change this value dynamically so that each thread uses a different port. – Parimal Jun 06 '14 at 15:11
0

Agree with nick, you will have to write a mechanism to listen on multiple ports, or rather spawn ports as per requirement.

You can also refer the use case of tomcat, we can spawn multiple instances of tomcat for multipe builds, it uses some mechanism to do it. Good use-case to learn about it.

Apurv Nerlekar
  • 2,310
  • 1
  • 21
  • 29
  • We changed chef_zero[:port] in the knife.rb file before running each knife solo cook. That worked till today morning. From today morning, the knife solo isn't creating any listening ports at all. There was a new release over the weekend, the issue seems to be fixed. – Parimal Jun 09 '14 at 13:57