Jira (PUP-11158) An environment may be reloaded during a single compilation

18 views
Skip to first unread message

Josh Cooper (Jira)

unread,
Jul 2, 2021, 7:44:02 PM7/2/21
to puppe...@googlegroups.com
Josh Cooper created an issue
 
Puppet / Bug PUP-11158
An environment may be reloaded during a single compilation
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2021/07/02 4:43 PM
Priority: Normal Normal
Reporter: Josh Cooper

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 Dreyer says it's important for versioned code deploys to keep the same environment object throughout a compile.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Josh Cooper (Jira)

unread,
Jul 2, 2021, 7:46:01 PM7/2/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 2, 2021, 7:46:03 PM7/2/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Platform Core KANBAN

Josh Cooper (Jira)

unread,
Jul 6, 2021, 10:52:01 AM7/6/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 7, 2021, 7:26:01 PM7/7/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 7, 2021, 7:26:01 PM7/7/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 20, 2021, 10:28:03 PM7/20/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 27, 2021, 9:29:03 PM7/27/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 29, 2021, 7:17:03 PM7/29/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 29, 2021, 7:19:03 PM7/29/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 29, 2021, 7:27:03 PM7/29/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Release Notes: Bug Fix
Release Notes Summary: Previously, Puppet Server could expire an environment and reload it, while it was being used to compile a catalog. If translations were enabled (Puppet[:disable_i18n] set to false), then compilation could fail. Now Puppet Server prevents environments from being reloaded while they are in use, and instead reloads the environment the next time it is requested.

Josh Cooper (Jira)

unread,
Jul 30, 2021, 2:17:03 PM7/30/21
to puppe...@googlegroups.com

Claire Cadman (Jira)

unread,
Aug 11, 2021, 9:00:03 AM8/11/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages