diff options
-rw-r--r-- | CHANGELOG.md | 6 | ||||
-rw-r--r-- | Gemfile.lock | 10 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | chef-config/lib/chef-config/version.rb | 2 | ||||
-rw-r--r-- | lib/chef/client.rb | 44 | ||||
-rw-r--r-- | lib/chef/version.rb | 2 | ||||
-rw-r--r-- | spec/support/shared/context/client.rb | 7 | ||||
-rw-r--r-- | spec/unit/client_spec.rb | 49 |
8 files changed, 111 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index f40acb7040..73a5e6f4e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ This changelog reflects the current state of chef's master branch on github and may not reflect the current released version of chef, which is [![Gem Version](https://badge.fury.io/rb/chef.svg)](https://badge.fury.io/rb/chef). -## [v13.0.108](https://github.com/chef/chef/tree/v13.0.108) (2017-04-06) -[Full Changelog](https://github.com/chef/chef/compare/v12.19.36...v13.0.108) +## [v13.0.110](https://github.com/chef/chef/tree/v13.0.110) (2017-04-06) +[Full Changelog](https://github.com/chef/chef/compare/v12.19.36...v13.0.110) **Merged pull requests:** @@ -10,6 +10,7 @@ This changelog reflects the current state of chef's master branch on github and - Ensure DataBagItems are a Mash [\#6018](https://github.com/chef/chef/pull/6018) ([thommay](https://github.com/thommay)) - RFC 59 - Load ohai plugins [\#6017](https://github.com/chef/chef/pull/6017) ([thommay](https://github.com/thommay)) - Implement RFC033: Root aliases [\#6015](https://github.com/chef/chef/pull/6015) ([coderanger](https://github.com/coderanger)) +- Chef-13: shell\_out PATH fixes and path\_sanity changes [\#6014](https://github.com/chef/chef/pull/6014) ([lamont-granquist](https://github.com/lamont-granquist)) - Remove use\_inline\_resources [\#6013](https://github.com/chef/chef/pull/6013) ([coderanger](https://github.com/coderanger)) - No more knife cookbook site vendor [\#6008](https://github.com/chef/chef/pull/6008) ([coderanger](https://github.com/coderanger)) - Allow lazy{} to be used in template resource variables. [\#6005](https://github.com/chef/chef/pull/6005) ([coderanger](https://github.com/coderanger)) @@ -60,7 +61,6 @@ This changelog reflects the current state of chef's master branch on github and - fix node\#debug\_value access through arrays [\#5911](https://github.com/chef/chef/pull/5911) ([lamont-granquist](https://github.com/lamont-granquist)) - Remove Chef::REST [\#5910](https://github.com/chef/chef/pull/5910) ([thommay](https://github.com/thommay)) - Chef-13: Nillable properties [\#5907](https://github.com/chef/chef/pull/5907) ([lamont-granquist](https://github.com/lamont-granquist)) -- Chef-13: freeze merged node attribute [\#5905](https://github.com/chef/chef/pull/5905) ([lamont-granquist](https://github.com/lamont-granquist)) ## [v12.19.33](https://github.com/chef/chef/tree/v12.19.33) (2017-02-16) [Full Changelog](https://github.com/chef/chef/compare/v12.18.31...v12.19.33) diff --git a/Gemfile.lock b/Gemfile.lock index 2a9bf4df03..2e4a6a114f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -113,10 +113,10 @@ GIT PATH remote: . specs: - chef (13.0.109) + chef (13.0.111) addressable bundler (>= 1.10) - chef-config (= 13.0.109) + chef-config (= 13.0.111) chef-zero (>= 13.0) diff-lcs (~> 1.2, >= 1.2.4) erubis (~> 2.7) @@ -143,10 +143,10 @@ PATH specinfra (~> 2.10) syslog-logger (~> 1.6) uuidtools (~> 2.1.5) - chef (13.0.109-universal-mingw32) + chef (13.0.111-universal-mingw32) addressable bundler (>= 1.10) - chef-config (= 13.0.109) + chef-config (= 13.0.111) chef-zero (>= 13.0) diff-lcs (~> 1.2, >= 1.2.4) erubis (~> 2.7) @@ -188,7 +188,7 @@ PATH PATH remote: chef-config specs: - chef-config (13.0.109) + chef-config (13.0.111) addressable fuzzyurl mixlib-config (~> 2.0) @@ -1 +1 @@ -13.0.109
\ No newline at end of file +13.0.111
\ No newline at end of file diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb index 62fd262db2..c68ef92303 100644 --- a/chef-config/lib/chef-config/version.rb +++ b/chef-config/lib/chef-config/version.rb @@ -21,7 +21,7 @@ module ChefConfig CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__) - VERSION = "13.0.109" + VERSION = "13.0.111" end # diff --git a/lib/chef/client.rb b/lib/chef/client.rb index c3eaa02bed..06325e0a23 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -280,6 +280,8 @@ class Chef run_context = setup_run_context + load_required_recipe(@rest, run_context) unless Chef::Config[:solo_legacy_mode] + if Chef::Config[:audit_mode] != :audit_only converge_error = converge_and_save(run_context) end @@ -515,6 +517,48 @@ class Chef end # + # Adds a required recipe as specified by the Chef Server + # + # @return The modified run context + # + # @api private + # + # TODO: @rest doesn't appear to be used anywhere outside + # of client.register except for here. If it's common practice + # to create your own rest client, perhaps we should do that + # here but it seems more appropriate to reuse one that we + # know is already created. for ease of testing, we'll pass + # the existing rest client in as a parameter + # + def load_required_recipe(rest, run_context) + required_recipe_contents = rest.get("required_recipe") + Chef::FileCache.store("required_recipe", required_recipe_contents) + required_recipe_file = Chef::FileCache.load("required_recipe", false) + + # TODO: add integration tests with resource reporting turned on + # (presumably requires changes to chef-zero) + # + # Chef::Recipe.new takes a cookbook name and a recipe name along + # with the run context. These names are eventually used in the + # resource reporter, and if the cookbook name cannot be found in the + # cookbook collection then we will fail with an exception. Cases where + # we currently also fail: + # - specific recipes + # - chef-apply would fail if resource reporting was enabled + # + recipe = Chef::Recipe.new(nil, nil, run_context) + recipe.from_file(required_recipe_file) + run_context + rescue Net::HTTPServerException => e + case e.response + when Net::HTTPNotFound + Chef::Log.info("Required Recipe not found") + else + raise + end + end + + # # The PolicyBuilder strategy for figuring out run list and cookbooks. # # @return [Chef::PolicyBuilder::Policyfile, Chef::PolicyBuilder::ExpandNodeObject] diff --git a/lib/chef/version.rb b/lib/chef/version.rb index c002477459..15fcb08879 100644 --- a/lib/chef/version.rb +++ b/lib/chef/version.rb @@ -21,7 +21,7 @@ class Chef CHEF_ROOT = File.expand_path("../..", __FILE__) - VERSION = "13.0.109" + VERSION = "13.0.111" end # diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb index 3c86e49882..19ce82fa15 100644 --- a/spec/support/shared/context/client.rb +++ b/spec/support/shared/context/client.rb @@ -135,6 +135,12 @@ shared_context "a client run" do and_return({}) end + def stub_for_required_recipe + response = Net::HTTPNotFound.new("1.1", "404", "Not Found") + exception = Net::HTTPServerException.new('404 "Not Found"', response) + expect(http_node_load).to receive(:get).with("required_recipe").and_raise(exception) + end + def stub_for_converge # define me end @@ -165,6 +171,7 @@ shared_context "a client run" do stub_for_data_collector_init stub_for_node_load stub_for_sync_cookbooks + stub_for_required_recipe stub_for_converge stub_for_audit stub_for_node_save diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index a2bb573e15..064876a82f 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -394,6 +394,55 @@ describe Chef::Client do end end + describe "load_required_recipe" do + let(:rest) { double("Chef::ServerAPI (required recipe)") } + let(:run_context) { double("Chef::RunContext") } + let(:recipe) { double("Chef::Recipe (required recipe)") } + let(:required_recipe) do + <<EOM +fake_recipe_variable = "for reals" +EOM + end + + context "when required_recipe is configured" do + + before(:each) do + expect(rest).to receive(:get).with("required_recipe").and_return(required_recipe) + expect(Chef::Recipe).to receive(:new).with(nil, nil, run_context).and_return(recipe) + expect(recipe).to receive(:from_file) + end + + it "fetches the recipe and adds it to the run context" do + client.load_required_recipe(rest, run_context) + end + + context "when the required_recipe has bad contents" do + let(:required_recipe) do + <<EOM +this is not a recipe +EOM + end + it "should not raise an error" do + expect { client.load_required_recipe(rest, run_context) }.not_to raise_error() + end + end + end + + context "when required_recipe returns 404" do + let(:http_response) { Net::HTTPNotFound.new("1.1", "404", "Not Found") } + let(:http_exception) { Net::HTTPServerException.new('404 "Not Found"', http_response) } + + before(:each) do + expect(rest).to receive(:get).with("required_recipe").and_raise(http_exception) + end + + it "should log and continue on" do + expect(Chef::Log).to receive(:info) + client.load_required_recipe(rest, run_context) + end + end + end + describe "windows_admin_check" do context "platform is not windows" do before do |