Issue #18187 has been updated by Adrien Thebo. Status changed from Merged - Pending Release to Code Insufficient
The implementation added in pull request 18187 has some pretty severe impacts with respect to the Puppet logging parser functions. Specifically those functions are attached to the `*root*` environment only, and when the root environment is cleared they are not re-added. If the `*root*` environment is going to be cleared along with all other environments then the logging functions need to be extracted from the Puppet::Parser::Functions module and implemented in a standalone manner, or somehow re-attached to the root environment. ---------------------------------------- Bug #18187: Cached *root* environment isn't cleared when Puppet::Node::Environment.clear is called https://projects.puppetlabs.com/issues/18187#change-82798 Author: Dominic Cleal Status: Code Insufficient Priority: Normal Assignee: Dominic Cleal Category: autoloader Target version: 3.1.1 Affected Puppet version: 2.7.20 Keywords: autoloader environments type regression Branch: https://github.com/puppetlabs/puppet/pull/1455 2.7.20 included a backport of a performance fix, which included a change to how types are autoloaded. [commit 8173a6e6c199426381f1f9fb8d0a71e0d0c12f2a](https://github.com/puppetlabs/puppet/commit/8173a6e6c199426381f1f9fb8d0a71e0d0c12f2a) commit 8173a6e6c199426381f1f9fb8d0a71e0d0c12f2a Author: Daniel Pittman <[email protected]> Date: Mon Jul 16 23:40:31 2012 -0700 Avoid object creation/destruction when possible. Object creation and destruction, even over a short time-frame, is expensive, so where we can avoid it we should. [..] diff --git a/lib/puppet/metatype/manager.rb b/lib/puppet/metatype/manager.rb index 597a89f..dfcc74d 100644 --- a/lib/puppet/metatype/manager.rb +++ b/lib/puppet/metatype/manager.rb @@ -108,17 +108,24 @@ module Manager [..] + # Try loading the type. + if typeloader.load(name, Puppet::Node::Environment.current) + Puppet.warning "Loaded puppet/type/#{name} but no class was created" unless @types.include? name end This happens to fix #13858, but now makes the autoloader for types depend on the current environment. I run a module spec and load types from a `modulepath` (set up in my module's spec_helper for third party modules). The spec_helper looks a bit like this: require 'puppetlabs_spec_helper/puppetlabs_spec_helper' Puppet[:modulepath] = File.join(dir, '..', 'modules') Puppet is initialised, settings are loaded by the pl_spec_helper / testhelper, then I specify a new modulepath, then begin loading types and testing them. The autoloader calls: real_env = Puppet::Node::Environment.new(env) With 2.7.19, env would have been nil (since none was passed in) and so `Puppet::Node::Environment` returns the "production" environment. 2.7.20 (see commit above) gets the "*root*" environment from `Puppet::Node::Environment.current` and passes it in. Both `TestHelper` and `Puppet::Util::Settings` call `Puppet::Node::Environment.clear` when things change (i.e. the modulepath I'm setting), but this doesn't clear the special `*root*` environment. This causes the old modulepath to remain cached in both the *root* environment itself and the autoloader (which has a thread cache based on the environment object), therefore types in the new modulepath can't be found. With 3.1.0 and Josh's fix in #15529, this isn't a problem since the modulepath won't get cached until app_defaults_initialized becomes true, which is just before the new modulepath is set, so all is OK. -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/puppet-bugs?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
