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

Apply parses everything twice



    • Bug
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • PUP 3.7.0
    • Compiler
    • None


      When the runtime creates Puppet::Resource instances, an attempt is made to lookup its type. This means that code will attempt to lookup the type in known_resource_types. If known_resource_type is nil, the runtime will issue a call to initial_import which is the starting point of parsing and evaluating code.

      The Puppet::Resource#envronment method attempts to figure out which environment to use (since that hold on to known_resource_type by looking at the resource instance's catalog's environment. The problem is when resource instances are created for the purpose of acting as a reference to a resource (rather than the instance itself), since such references are never contained in a Catalog per se. The environment method used a synthetic environment called NONE internally, and when NONE is not initialized the initial_import ill be called to again perform parsing.

      This is fixed in this commit: https://github.com/hlindberg/puppet/commit/3ab10bc6ffe724a204e0fd2d1df0e651c9d93d66

      as part of PUP-2714, where this problem was detected.

      Currently, the fix is is part of https://github.com/puppetlabs/puppet/pull/2749

      But the issue is serious enough to warrant this ticket. There is a strong suspicion that the behavior also can cause leakage into the NONE environment (one env leaking into another). It is also probably worse for directory based environments since there is no file watching, and thus parsing never skips files when asked to parse them.

      Not sure what the right action here is except simply correcting the faulty behavior as per the PR-2749. Longer term, the notion of resource references requiring access to their type is something we want to get rid off.


        Issue Links



              Unassigned Unassigned
              henrik.lindberg Henrik Lindberg
              Kurt Wall Kurt Wall
              0 Vote for this issue
              4 Start watching this issue



                Zendesk Support