Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
None
-
Coremunity
-
Platform Core KANBAN
-
Needs Assessment
-
Bug Fix
-
-
Needs Assessment
Description
The environment cache's keys may be strings or symbols, so you can end up with same environment cached under two different names (see PUP-10955). We tried fixing the issue, but it turns out we're currently relying on the symbol/string confusion to prevent an environment from being reloaded during a compilation.
For example, given this script:
require 'puppet' |
Locale.current = 'ja_JP' |
Puppet.initialize_settings
|
Puppet::GettextConfig.setup_locale
|
Puppet::Resource::Catalog.indirection.terminus_class = :compiler |
Puppet[:log_level] = 'debug' |
Puppet::Util::Log.newdestination(:console) |
|
Puppet::ApplicationSupport.push_application_context(Puppet::Util::RunMode[:server]) |
catalog = Puppet::Resource::Catalog.indirection.find(Puppet[:certname], environment: :production) |
puts catalog.resource(:notify, 'happy')[:message] |
Results in the following:
$ bundle exec puppet module install eputnam-i18ndemo
|
$ bundle exec ruby envs.rb
|
...
|
Debug: Loaded translations for puppetlabs-stdlib.
|
Debug: Loaded translations for eputnam-i18ndemo.
|
Debug: Evicting cache entry for environment 'production'
|
Debug: Deleted current text domain :production: true
|
Debug: Path to /home/josh/.puppetlabs/etc/code/environments/production does not exist, using default environment.conf
|
...`
|
Notice: Compiled catalog for localhost in environment production in 0.02 seconds
|
--*IT'S HAPPY FUN TIME*--
|
yppah
|
--*IT'S HAPPY FUN TIME*--
|
Note the translations are loaded, but the environment is cleared and the text domain is deleted prior to compilation, so we end up with the non-localized message IT'S HAPPY FUN TIME.
Changing the environment parameter to a string, prevents the environment from being cleared:
catalog = Puppet::Resource::Catalog.indirection.find(Puppet[:certname], environment: 'production') |
And we get the localized message:
--*eputnam-i18ndemo function: それは楽しい時間です*--
|
yppah
|
--*eputnam-i18ndemo function: それは楽しい時間です*--
|
We should be explicit about not reloading an environment during a single compilation. If environment_timeout=0, then the environment should be reloaded during the next compilation (or any indirected request).
Also maggie says it's important for versioned code deploys to keep the same environment object throughout a compile.
Attachments
Issue Links
- blocks
-
PUP-10955 Environment caches string and symbol environment names differently
-
- Resolved
-