summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Anderson <mark@opscode.com>2012-11-05 14:43:00 -0800
committerMark Anderson <mark@opscode.com>2012-11-05 14:43:00 -0800
commit5527eb7b347ec70aaef353dc7780ed6994720847 (patch)
tree3a5baeb3d25b206f3723a663bc5b2f7d0e02d3d6
parentdce247b4f7aff7a5a4546ffc3cab8c7570992637 (diff)
downloadchef-5527eb7b347ec70aaef353dc7780ed6994720847.tar.gz
Add configurable timeout.
-rw-r--r--chef/lib/chef/config.rb3
-rw-r--r--chef/lib/chef/cookbook_version_selector.rb2
2 files changed, 4 insertions, 1 deletions
diff --git a/chef/lib/chef/config.rb b/chef/lib/chef/config.rb
index 1182c79fc4..81815d7694 100644
--- a/chef/lib/chef/config.rb
+++ b/chef/lib/chef/config.rb
@@ -168,6 +168,9 @@ class Chef
solo false
splay nil
+ # Dep solver timeout; if finding a solution takes longer than this, we fail
+ dep_selector_timeout 5
+
# Set these to enable SSL authentication / mutual-authentication
# with the server
ssl_client_cert nil
diff --git a/chef/lib/chef/cookbook_version_selector.rb b/chef/lib/chef/cookbook_version_selector.rb
index 903c680a7d..9bb6cc6e2b 100644
--- a/chef/lib/chef/cookbook_version_selector.rb
+++ b/chef/lib/chef/cookbook_version_selector.rb
@@ -105,7 +105,7 @@ class Chef
# unsatisfiability and try to hint at what might be wrong.
soln =
begin
- DepSelector::Selector.new(dep_graph).find_solution(cookbook_constraints, all_packages)
+ DepSelector::Selector.new(dep_graph, Chef::Config[:dep_selector_timeout]).find_solution(cookbook_constraints, all_packages)
rescue DepSelector::Exceptions::InvalidSolutionConstraints => e
non_existent_cookbooks = e.non_existent_packages.map {|constraint| constraint.package.name}
cookbooks_with_no_matching_versions = e.constrained_to_no_versions.map {|constraint| constraint.package.name}