Darren Oakey
Darren Oakey

Reputation: 3654

How do I fix startup delays in chef-solo

Using chef solo, calling it directly - with logging set as high as possible, this is what I see in a tail:

[2015-03-24T12:21:48+11:00] INFO: Forking chef instance to converge...
[2015-03-24T12:21:48+11:00] DEBUG: Fork successful. Waiting for new chef pid: 5571
[2015-03-24T12:21:48+11:00] DEBUG: Forked instance now converging
[2015-03-24T12:21:49+11:00] INFO: *** Chef 11.8.2 ***
[2015-03-24T12:21:49+11:00] INFO: Chef-client pid: 5571
[2015-03-24T12:25:41+11:00] DEBUG: Building node object for localhost.localdomain
...

and then it continues and goes on to work perfectly. Notice in between the last two lines, there is a delay which varies between 3 and 5 minutes! With no explanation of what it's doing, nothing obvious on netstat or top - I'm at a loss for how to troubleshoot this.

I thought it might be a proxy thing, but setting the correct proxies in /etc/chef/client.rb changed nothing. Any ideas how I get rid of this delay?

Upvotes: 1

Views: 592

Answers (1)

jtimberman
jtimberman

Reputation: 8258

The first thing that Chef does when it starts - whether it's chef-solo or chef-client, is profile the system with ohai.

A main difference between chef-solo and chef-client is that debug log level will show the ohai output with chef-client, but it does not with chef-solo.

Depending on your system's configuration, this can take a long time to do, as it runs through a plethora of plugins. In particular, if you have a Linux system that is connected to Active Directory, it can take awhile to retrieve the user/group records via AD, which is why Ohai supports disabling plugins. Also, if you're running Chef and Ohai on a Windows system, it can take a long time.

To disable plugins, you need to edit the appropriate application's configuration file.

  • chef-solo uses /etc/chef/solo.rb by default
  • chef-client uses /etc/chef/client.rb by default

Add the following line to the appropriate config:

Ohai::Config[:disabled_plugins] = [:Passwd]

to disable the user/group lookup that might use Active Directory.

Also, I see from the output that you're using Chef 11.8.2 which came out December 3, 2013 (over a year ago as of this answer). It's possible that a performance improvement was introduced since then.

However, if you're not specifically beholden to chef-solo, you might try using chef-client with local mode. There is more information about how to switch in a blog post by Julian Dunn on Chef's site. If you need further assistance I strongly suggest the Chef irc channel on irc.freenode.net, or the chef mailing list.

Upvotes: 3

Related Questions