Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-10955

Environment caches string and symbol environment names differently

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • None
    • PUP 6.25.0, PUP 7.10.0
    • None
    • Night's Watch
    • 2
    • NW - 2021-06-30, NW - 2021-07-14, NW - 2021-07-28, NW - 2021-08-11
    • Needs Assessment
    • Bug Fix
    • Fixes a bug that could result in puppet caching duplicate copies of an environment.
    • Needs Assessment

    Description

      The Puppet::Environments::Cached#get method says it accepts Strings or Symbols, but it doesn't normalize the name when getting/setting the environment in the cache. So you can end up caching environments for "production" and :production.

      Agent side we lookup the environment based on the Puppet[:environment] setting. Server side we lookup the environment from a query parameter. But there are other entry points like Bolt and non-indirected REST APIs, so it would be good to fix this.

      require 'puppet'
      Puppet.initialize_settings
      Puppet::Util::Log.newdestination(:console)
      Puppet::ApplicationSupport.push_application_context(Puppet::Util::RunMode[:user])
      envs = Puppet.lookup(:environments)
      envs.get!('production')
      envs.get!(:production)
      pp envs.instance_variable_get(:@cache).keys
      

      $ bx ruby cache.rb
      ["production", :production]
      

      Attachments

        Issue Links

          Activity

            People

              luchian.nemes Luchian Nemes
              josh Josh Cooper
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support