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

The environment cache erroneously binds topscope and compilation gets values from "first compilation after restart"

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: PUP 4.5.3, PUP 4.6.0
    • Fix Version/s: PUP 4.6.1
    • Component/s: None
    • Labels:
      None
    • Template:
    • Epic Link:
    • Story Points:
      2
    • Sprint:
      Language 2016-08-10, Language 2016-08-24
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      Under certain circumstances when environment_timeout was set to a value > 0 the top scope of the first used compilation request would become sticky and lookups of variables made by functions would get values from the first compilation in that environment. This also caused memory to leak and could in some situations lead to an Out of Memory error.
      Show
      Under certain circumstances when environment_timeout was set to a value > 0 the top scope of the first used compilation request would become sticky and lookups of variables made by functions would get values from the first compilation in that environment. This also caused memory to leak and could in some situations lead to an Out of Memory error.

      Description

      There's a fairly detailed reproducible test case with more details here.

      In short, the resultant value of a function defined in the Puppet language which does not reference any Ruby code will be cached when environment_timeout is set to unlimited. This cache is generated separately based on parameters passed to the function, but it is shared between runs and between nodes. This causes a problem when the function refers to fact values, because if a fact value used by the function changed between runs or between nodes, the result of the function may not be accurate.

      This behavior does not occur if the function calls a Ruby function. It also does not occur if environment_timeout is set to 0.

      If the expected use of functions defined in the Puppet language is to only ever reference data that is passed in directly via variables, then the scoping should reflect that by not making any top-scope variables available within a function, although this would make functions different than every other construct in Puppet, so I don't think that would be a good resolution. Better is to stop this result caching behavior from occurring.

      This occurs at least in Puppet Server 2.4.0 on CentOS 7, both FOSS and PE builds. I have not tested this in other versions or under other conditions.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              john.duarte John Duarte
              Reporter:
              lexa Lexa Whitehurst
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support