From 66015ba654469f4dacfd78d40b02aafee52bbf1b Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Mon, 11 Mar 2019 11:49:31 -0700 Subject: Extract Action Collection from Data Collector See the PR for details on this change. Signed-off-by: Lamont Granquist --- lib/chef/policy_builder/dynamic.rb | 3 ++- lib/chef/policy_builder/expand_node_object.rb | 17 ++++++++++++----- lib/chef/policy_builder/policyfile.rb | 4 ++++ 3 files changed, 18 insertions(+), 6 deletions(-) (limited to 'lib/chef/policy_builder') diff --git a/lib/chef/policy_builder/dynamic.rb b/lib/chef/policy_builder/dynamic.rb index 8ce4f25bfa..2c49f41656 100644 --- a/lib/chef/policy_builder/dynamic.rb +++ b/lib/chef/policy_builder/dynamic.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo () -# Copyright:: Copyright 2015-2016, Chef Software, Inc. +# Copyright:: Copyright 2015-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -74,6 +74,7 @@ class Chef select_implementation(node) implementation.finish_load_node(node) node + events.node_load_success(node) rescue Exception => e events.node_load_failed(node_name, e, config) raise diff --git a/lib/chef/policy_builder/expand_node_object.rb b/lib/chef/policy_builder/expand_node_object.rb index c91c74b047..839c3bb526 100644 --- a/lib/chef/policy_builder/expand_node_object.rb +++ b/lib/chef/policy_builder/expand_node_object.rb @@ -3,7 +3,7 @@ # Author:: Tim Hinderliter () # Author:: Christopher Walters () # Author:: Daniel DeLeo () -# Copyright:: Copyright 2008-2017, Chef Software Inc. +# Copyright:: Copyright 2008-2018, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -68,6 +68,11 @@ class Chef Chef.set_run_context(run_context) end + # This not only creates the run_context but this is where we kick off + # compiling the entire expanded run_list, loading all the libraries, resources, + # attribute files and recipes, and constructing the entire resource collection. + # (FIXME: break up creating the run_context and compiling the cookbooks) + # def setup_run_context(specific_recipes = nil) if Chef::Config[:solo_legacy_mode] Chef::Cookbook::FileVendor.fetch_from_disk(Chef::Config[:cookbook_path]) @@ -88,18 +93,20 @@ class Chef run_context = Chef::RunContext.new(node, cookbook_collection, @events) end - # TODO: this is really obviously not the place for this - # FIXME: need same edits + # TODO: move this into the cookbook_compilation_start hook setup_chef_class(run_context) - # TODO: this is not the place for this. It should be in Runner or - # CookbookCompiler or something. + events.cookbook_compilation_start(run_context) + run_context.load(@run_list_expansion) if specific_recipes specific_recipes.each do |recipe_file| run_context.load_recipe_file(recipe_file) end end + + events.cookbook_compilation_complete(run_context) + run_context end diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb index 3e7462f0ed..bedbe651a1 100644 --- a/lib/chef/policy_builder/policyfile.rb +++ b/lib/chef/policy_builder/policyfile.rb @@ -192,8 +192,12 @@ class Chef setup_chef_class(run_context) + events.cookbook_compilation_start(run_context) + run_context.load(run_list_expansion_ish) + events.cookbook_compilation_complete(run_context) + setup_chef_class(run_context) run_context end -- cgit v1.2.1