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

Environment caches string and symbol environment names differently

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 6.25.0, PUP 7.10.0
    • Component/s: None
    • Labels:
    • Template:
      PUP Bug Template
    • Team:
      Night's Watch
    • Story Points:
      2
    • Sprint:
      NW - 2021-06-30, NW - 2021-07-14, NW - 2021-07-28, NW - 2021-08-11
    • Method Found:
      Needs Assessment
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Fixes a bug that could result in puppet caching duplicate copies of an environment.
    • QA Risk Assessment:
      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

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

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support