Jira (PUP-10308) Puppet.lookup(:current_environment) is wrong if environment changes during convergence

1 view
Skip to first unread message

Josh Cooper (JIRA)

unread,
Feb 21, 2020, 1:12:07 PM2/21/20
to puppe...@googlegroups.com
Josh Cooper created an issue
 
Puppet / Bug PUP-10308
Puppet.lookup(:current_environment) is wrong if environment changes during convergence
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2020/02/21 10:11 AM
Priority: Normal Normal
Reporter: Josh Cooper

At the start of the configurer run, puppet pushes its configured environment (from Puppet[:environment]) or the server-specified environment (from the ENC) onto the context in https://github.com/puppetlabs/puppet/blob/6.13.0/lib/puppet/configurer.rb#L319-L331

However, if pluginsync causes environment to change, then the agent switches to the new environment, but Puppet.lookup(:current_environment) still returns old value, while Puppet::Resource::Catalog#environment returns the new value:

$ bx puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Notice: Local environment: 'production' doesn't match server specified environment 'dev', restarting agent run with environment 'dev'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Caching catalog for XXX
Info: Applying configuration version '1582308523'
 
[261, 270] in /Users/josh/work/puppet/lib/puppet/type/file/source.rb
   261:       end
   262:     end
   263:
   264:     def each_chunk_from
   265:       require 'byebug'; byebug
=> 266:       if Puppet[:default_file_terminus] == :file_server && scheme == 'puppet' && (uri.host.nil? || uri.host.empty?)
   267:         chunk_file_from_disk(metadata.path) { |chunk| yield chunk }
   268:       elsif local?
   269:         chunk_file_from_disk(full_path) { |chunk| yield chunk }
   270:       else
(byebug) Puppet.lookup(:current_environment)
<Puppet::Node::Environment::Remote:70205531253460 @name="production" @manifest="no_manifest" @modulepath="" >
(byebug) resource.catalog.environment
"dev"

Puppet relies on the catalog's environment being correct when retrieving file metadata & content, such as https://github.com/puppetlabs/puppet/blob/6.13.0/lib/puppet/type/file/source.rb#L194

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Josh Cooper (Jira)

unread,
Mar 18, 2020, 4:10:04 PM3/18/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Epic Link: PUP-7563
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Josh Cooper (Jira)

unread,
Jun 5, 2020, 5:51:02 PM6/5/20
to puppe...@googlegroups.com

Jenna McCarthy (Jira)

unread,
Jun 25, 2021, 6:39:03 PM6/25/21
to puppe...@googlegroups.com
Jenna McCarthy updated an issue
Change By: Jenna McCarthy
Labels: 001G000001p3dQmIAI
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Josh Cooper (Jira)

unread,
Jun 28, 2021, 1:27:01 PM6/28/21
to puppe...@googlegroups.com

Ciprian Badescu (Jira)

unread,
Jun 30, 2021, 4:39:02 AM6/30/21
to puppe...@googlegroups.com

Ciprian Badescu (Jira)

unread,
Jun 30, 2021, 4:44:02 AM6/30/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 1, 2021, 4:10:02 AM7/1/21
to puppe...@googlegroups.com

Victor Bobosila (Jira)

unread,
Jul 2, 2021, 9:25:02 AM7/2/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 2, 2021, 12:40:03 PM7/2/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Fix Version/s: PUP 7.9.0
Fix Version/s: PUP 6.24.0

Ciprian Badescu (Jira)

unread,
Jul 5, 2021, 3:23:02 AM7/5/21
to puppe...@googlegroups.com
Ciprian Badescu updated an issue
Change By: Ciprian Badescu
Fix Version/s: PUP 7.9.0
Fix Version/s: PUP 6.24.0

Ciprian Badescu (Jira)

unread,
Jul 7, 2021, 3:51:03 AM7/7/21
to puppe...@googlegroups.com

Jenna McCarthy (Jira)

unread,
Jul 9, 2021, 9:40:01 AM7/9/21
to puppe...@googlegroups.com

Ciprian Badescu (Jira)

unread,
Jul 14, 2021, 4:49:02 AM7/14/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 22, 2021, 1:00:03 PM7/22/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Fix Version/s: PUP 7.10.0
Fix Version/s: PUP 6.25.0

Josh Cooper (Jira)

unread,
Jul 22, 2021, 1:00:07 PM7/22/21
to puppe...@googlegroups.com

Gheorghe Popescu (Jira)

unread,
Jul 26, 2021, 2:59:02 AM7/26/21
to puppe...@googlegroups.com

Gheorghe Popescu (Jira)

unread,
Jul 26, 2021, 2:59:02 AM7/26/21
to puppe...@googlegroups.com
Gheorghe Popescu updated an issue
Change By: Gheorghe Popescu
Release Notes Summary: Fixed a bug where an old environment could be used if the environment has changed due to pluginsync.

Claire Cadman (Jira)

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