summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2014-03-14 13:11:00 -0700
committerdanielsdeleo <dan@getchef.com>2014-03-14 14:09:37 -0700
commit33b2ae7adef917ddcafb93f3bca6a28d0f750c03 (patch)
treee664df769ecce7e31824bc3db0129760749fd761
parentaa9585f2f7d214c667fcba4cbf61e7e8114484ab (diff)
downloadchef-33b2ae7adef917ddcafb93f3bca6a28d0f750c03.tar.gz
Change missing dependency from hard error to warning for now.
-rw-r--r--CHANGELOG.md4
-rw-r--r--RELEASE_NOTES.md6
-rw-r--r--lib/chef/exceptions.rb2
-rw-r--r--lib/chef/run_context.rb3
-rw-r--r--spec/integration/solo/solo_spec.rb4
-rw-r--r--spec/unit/run_context_spec.rb4
6 files changed, 13 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1b27fc25b4..3a92900fa8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,8 +2,8 @@
## Unreleased
-* Including a recipe from a cookbook not in the dependency graph raises
- a MissingCookbookDependency exception. Fixes CHEF-4367.
+* Including a recipe from a cookbook not in the dependency graph logs
+ a MissingCookbookDependency warning. Fixes CHEF-4367.
* Improves syntax check speed for Ruby 1.9+, especially when using bundler.
* Send X-Remote-Request-Id header in order to be able to correlate actions during a single run.
* Fix for CHEF-5048.
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 0a34f5619e..9885663873 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -8,7 +8,7 @@ Details about the thing that changed that needs to get included in the Release N
-->
# Chef Client Release Notes:
-#### Chef Solo Missing Dependency Improvments ([CHEF-4367](https://tickets.opscode.com/browse/CHEF-4367))
+#### Chef Solo Missing Dependency Warning ([CHEF-4367](https://tickets.opscode.com/browse/CHEF-4367))
Chef 11.0 introduced ordered evaluation of non-recipe files in
cookbooks, based on the dependencies specified in your cookbooks'
@@ -23,8 +23,8 @@ did not suggest the actual cause of the failure.
We've added a check to `include_recipe` so that attempting to include a
recipe which is not a dependency of any cookbook specified in the run
-list will now raise an error with a message describing the problem and
-solution.
+list will now log a warning with a message describing the problem and
+solution. In the future, this warning will become an error.
#### reboot_pending?
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
index 8df49b9303..bd99cb3ebd 100644
--- a/lib/chef/exceptions.rb
+++ b/lib/chef/exceptions.rb
@@ -76,7 +76,7 @@ class Chef
class CookbookNotFoundInRepo < ArgumentError; end
class RecipeNotFound < ArgumentError; end
class AttributeNotFound < RuntimeError; end
- class MissingCookbookDependency < StandardError; end
+ class MissingCookbookDependency < StandardError; end # CHEF-5120
class InvalidCommandOption < RuntimeError; end
class CommandTimeout < RuntimeError; end
class RequestedUIDUnavailable < RuntimeError; end
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index b66e3e54c7..a102ef4692 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -145,7 +145,8 @@ class Chef
cookbook_name, recipe_short_name = Chef::Recipe.parse_recipe_name(recipe_name)
if unreachable_cookbook?(cookbook_name) # CHEF-4367
- raise(Exceptions::MissingCookbookDependency,<<-ERROR_MESSAGE)
+ Chef::Log.warn(<<-ERROR_MESSAGE)
+MissingCookbookDependency:
Recipe `#{recipe_name}` is not in the run_list, and cookbook '#{cookbook_name}'
is not a dependency of any cookbook in the run_list. To load this recipe,
first add a dependency on cookbook '#{cookbook_name}' in the cookbook you're
diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb
index f688a16430..23ec8d0bad 100644
--- a/spec/integration/solo/solo_spec.rb
+++ b/spec/integration/solo/solo_spec.rb
@@ -55,8 +55,8 @@ cookbook_path "#{path_to('cookbooks')}"
file_cache_path "#{path_to('config/cache')}"
EOM
result = shell_out("ruby bin/chef-solo -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", :cwd => chef_dir)
- result.exitstatus.should == 1
- result.stdout.should include("Chef::Exceptions::MissingCookbookDependency")
+ result.exitstatus.should == 0 # For CHEF-5120 this becomes 1
+ result.stdout.should include("WARN: MissingCookbookDependency")
end
end
diff --git a/spec/unit/run_context_spec.rb b/spec/unit/run_context_spec.rb
index f885f49770..813102527b 100644
--- a/spec/unit/run_context_spec.rb
+++ b/spec/unit/run_context_spec.rb
@@ -80,9 +80,11 @@ describe Chef::RunContext do
end
it "raises an error when attempting to include_recipe from a cookbook not reachable by run list or dependencies" do
+ @node.should_receive(:loaded_recipe).with(:ancient, "aliens")
lambda do
@run_context.include_recipe("ancient::aliens")
- end.should raise_error(Chef::Exceptions::MissingCookbookDependency)
+ # In CHEF-5120, this becomes a Chef::Exceptions::MissingCookbookDependency error:
+ end.should raise_error(Chef::Exceptions::CookbookNotFound)
end
end