Hello everyone,
As we’ve started to build up our cookbook library and the dependencies have grown, we’re running into a lot of dependency resolution issues. Since Chef has two dependency resolution mechanisms (Berkshelf
and chef-client
), we have two different errors.
We’ll have something like this happen when we do a chef-client
run:
$ sudo chef-client
Starting Chef Client, version 12.4.3
resolving cookbooks for run list: ["base_cookbook::recipe", "cookbookB::recipe"]
================================================================================
Error Resolving Cookbooks for Run List:
================================================================================
Cookbook dependency resolution error:
-------------------------------------
Error message: unable to solve dependencies in alotted time
You might be able to resolve this issue with:
1-) Removing cookbook versions that depend on deleted cookbooks.
2-) Removing unused cookbook versions.
3-) Pinning exact cookbook versions using environments.
Expanded Run List:
------------------
* base_cookbook::recipe
* cookbookB::recipe
Running handlers:
[2015-11-24T14:24:59-05:00] ERROR: Running exception handlers
Running handlers complete
[2015-11-24T14:24:59-05:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 11.843015546 seconds
[2015-11-24T14:24:59-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-11-24T14:24:59-05:00] ERROR: 412 "Precondition Failed"
[2015-11-24T14:24:59-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Given this node has only two items on the run list (a base cookbook and the node specific cookbook), we brought the base cookbook into cookbookB
's metadata.rb and tried to do a Berkshelf resolution. That hung for a long time and comes back with:
$ berks update
Resolving cookbook dependencies...
Fetching 'cookbookB' from source at .
Fetching cookbook index from https://supermarket.chef.io...
Fetching cookbook index from http://local.supermarket...
The dependency constraints could not be solved in the time allotted.
Unable to find a solution for demands: test-helper-cookbook (~> 2.1), cookbookB (1.3.0)
In both scenarios, the error messages are not clear as to what’s causing the conflicting dependency resolution. The approach that we usually take in this case is to take a look at the Berksfile.lock
in both cookbooks to try and find (by ) where the conflicts are, which is not ideal. In this particular case we actually haven’t found the issue yet.
We’ve tried bumping up the dependency resolution times on the Chef Server, but in these cases the dependencies are actually never resolved, and so chef converges just hung for 5 minutes. We’ve since reduced the time back to the default.
Am I missing something? Is there a trick that people have? Are there some other tools we can use to make this debugging easier?
P.S. I’ve read a bit about Policyfiles, do I understand correctly that this won’t happen there? At least we can catch these dependency resolution issues locally before they even make it to the server?
Thank you in advance!