Puppet agent 8.22.2: changing ‘environment’ in puppet.conf under a running daemon leaves the old environment active for anything that relies on Puppet.lookup(:current_environment). How to reproduce:
1. Start the agent daemon with ‘environment = new’ in puppet.conf.
2. Remove the setting (server-specified environment is production). The daemon logs “Config file ... changed; triggering re-parse”.
3. Next run: catalog is requested and compiled in production, but concat_file’s eval_generate requests file_metadata/modules/nftables/config/puppet-inet-filter.nft?environment=new. If ‘new’ no longer exists on the server: 404, “Could not retrieve source(s)“.
Cause (configurer.rb): after the re-parse, @environment = Puppet[:environment] is production, but push_current_environment_and_loaders isn’t called. The catalog environment matches @environment, the lastrunfile doesn’t trigger a switch, and :loaders already exists in the context. So :current_environment stays at the startup value, and Indirector::Request#environment falls back to it when no environment is passed.