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

Data Type casts cause Puppet Server to retain Compiler instances

    XMLWordPrintable

Details

    • Night's Watch
    • 3
    • NW - 2020-09-16, NW - 2020-09-30
    • Customer Feedback
    • 40701,41223
    • 2
    • Bug Fix
    • Fix Data Type casting retaining Compiler instances when running under JRuby
    • Needs Assessment

    Description

      Casting between Puppet Data Types, such as Integer("9"), will cause Puppet Server to retain Puppet::Parser::Catlog objects in memory after requests finish.

      See SERVER-2874 for more context and PE reproduction case.

      Reproduction Case

      • Install Puppet Server on CentOS 7 along with the Java development tools:

      yum install -y http://yum.puppetlabs.com/puppet6-release-el-7.noarch.rpm
      yum install -y puppetserver java-devel
      source /etc/profile.d/puppet-agent.sh
      

      • Install the `pupeptlabs-inifile` module and use it to enable JRuby class reification. This allows Ruby objects, like Puppet::Parser::Compiler, to be identified easily in the Java heap:

      puppet module install puppetlabs-inifile
       
      puppet apply <<'EOF'
      ini_subsetting { 'Enable JRuby reify.classes':
        ensure            => present,
        path              => '/etc/sysconfig/puppetserver',
        section           => '',
        key_val_separator => '=',
        setting           => 'JAVA_ARGS',
        subsetting        => '-Djruby.reify.classes',
        value             => '=true',
      }
      EOF
      

      • Bootstrap the CA, configure the agent, and start the puppetserver service:

      puppetserver ca setup
      puppet config set server $(hostname -f)
      systemctl start puppetserver
      

      • Give the service a trivial catalog to compile:

      cat <<'EOF' > /etc/puppetlabs/code/environments/production/manifests/site.pp
      node default {
        $string_version = "9"
        $version = Integer($string_version)
      }
      EOF
      

      • Run puppet a couple of times:

      puppet agent -t
      puppet agent -t
      

      • Check the number of Puppet::Parser::Compiler instances retained in Puppet Server memory:

      sudo -u puppet jmap -histo:live $(systemctl show -p MainPID puppetserver|cut -d= -f2)|fgrep 'rubyobj.Puppet.Parser.Compiler'
      

      Outcome

      After running the agent twice, the puppetserver service is retaining two Compiler instances in memory:

      # sudo -u puppet jmap -histo:live $(systemctl show -p MainPID puppetserver|cut -d= -f2)|fgrep 'rubyobj.Puppet.Parser.Compiler'
      5871:             2             64  rubyobj.Puppet.Parser.Compiler
      

      Expected Outcome

      No compiler instances should be retained as the compiler is discarded at the end of the request and the -histo:live flag forces a full garbage collection.

      Attachments

        Issue Links

          Activity

            People

              gabriel.nagy Gabriel Nagy
              chuck Charlie Sharpsteen
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support