diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-02-14 17:43:17 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2018-02-15 11:55:58 -0800 |
commit | 72e167a8eb50887c040857fb04e00421bbab84ef (patch) | |
tree | 84899a248191a4414eafeff25be23b63e8f91d42 | |
parent | bb87713458370485fb91be691356086fb98f055f (diff) | |
download | chef-72e167a8eb50887c040857fb04e00421bbab84ef.tar.gz |
reduce cache rebuilds more
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/node.rb | 10 | ||||
-rw-r--r-- | lib/chef/node/attribute.rb | 20 | ||||
-rw-r--r-- | lib/chef/policy_builder/expand_node_object.rb | 8 |
3 files changed, 22 insertions, 16 deletions
diff --git a/lib/chef/node.rb b/lib/chef/node.rb index 8fd809067d..c454044c80 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -435,11 +435,13 @@ class Chef Chef::Environment.load(chef_environment) end - attributes.env_default = loaded_environment.default_attributes - attributes.env_override = loaded_environment.override_attributes + attributes.defer_cache_resetting do + attributes.env_default = loaded_environment.default_attributes + attributes.env_override = loaded_environment.override_attributes - attribute.role_default = expansion.default_attrs - attributes.role_override = expansion.override_attrs + attribute.role_default = expansion.default_attrs + attributes.role_override = expansion.override_attrs + end end # Transform the node to a Hash diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb index 44ea157bc9..17d16f64c2 100644 --- a/lib/chef/node/attribute.rb +++ b/lib/chef/node/attribute.rb @@ -243,10 +243,21 @@ class Chef end end + # @api private def reset @deep_merge_cache = nil end + # avoid doing cache clearing work for an entire block of code, then nuke the entire cache + # @api private + def defer_cache_resetting + @disable_cache_reset = true + yield + @disable_cache_reset = false + reset + end + + # @api private def reset_cache(*path) return if @disable_cache_reset if path.empty? @@ -669,15 +680,6 @@ class Chef end end - # avoid doing cache clearing work for an entire block of code, then nuke the entire cache - # @api private - def defer_cache_resetting - @disable_cache_reset = true - yield - @disable_cache_reset = false - reset - end - end end end diff --git a/lib/chef/policy_builder/expand_node_object.rb b/lib/chef/policy_builder/expand_node_object.rb index d8f4f752de..72ab9b02f0 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 (<tim@chef.io>) # Author:: Christopher Walters (<cw@chef.io>) # Author:: Daniel DeLeo (<dan@chef.io>) -# Copyright:: Copyright 2008-2016 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"); @@ -149,8 +149,10 @@ class Chef # consume_external_attrs may add items to the run_list. Save the # expanded run_list, which we will pass to the server later to # determine which versions of cookbooks to use. - node.reset_defaults_and_overrides - node.consume_external_attrs(ohai_data, @json_attribs) + node.attributes.defer_cache_resetting do + node.reset_defaults_and_overrides + node.consume_external_attrs(ohai_data, @json_attribs) + end setup_run_list_override |