puppetlabs-toy-chest / puppetlabs-puppetserver_gem

This module provides management of Ruby gems for Puppet Server.
3 stars 24 forks source link

Can't list installed gems if memory is tight #21

Closed tskirvin closed 4 years ago

tskirvin commented 6 years ago

I'm trying to install hiera-eyaml with this gem, and getting this error, followed by trying to reinstall the gem every time:

Feb 26 07:28:46 ssipuppet10 puppet-agent[46223]: Could not match #
Feb 26 07:28:46 ssipuppet10 puppet-agent[46223]: Could not match # There is insufficient memory for the Java Runtime Environment to continue.
Feb 26 07:28:46 ssipuppet10 puppet-agent[46223]: Could not match # Native memory allocation (mmap) failed to map 80530636800 bytes for committing reserved memory.
Feb 26 07:28:46 ssipuppet10 puppet-agent[46223]: Could not match # An error report file with more information is saved as:
Feb 26 07:28:46 ssipuppet10 puppet-agent[46223]: Could not match # /root/hs_err_pid46911.log
Feb 26 07:28:47 ssipuppet10 puppet-agent[46223]: Could not match #
Feb 26 07:28:47 ssipuppet10 puppet-agent[46223]: Could not match # There is insufficient memory for the Java Runtime Environment to continue.
Feb 26 07:28:47 ssipuppet10 puppet-agent[46223]: Could not match # Native memory allocation (mmap) failed to map 80530636800 bytes for committing reserved memory.
Feb 26 07:28:47 ssipuppet10 puppet-agent[46223]: Could not match # An error report file with more information is saved as:
Feb 26 07:28:47 ssipuppet10 puppet-agent[46223]: Could not match # /root/hs_err_pid46994.log

The problem can be reproduced here:


ssipuppet10 ~# /opt/puppetlabs/server/bin/puppetserver gem list
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00007f97ac000000, 80530636800, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 80530636800 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /root/hs_err_pid21873.log```

The core issue seems to be that loading up the 'gem list' command requires loading up a whole puppet server, which seems problematic.
tskirvin commented 6 years ago

Those hs_err.log files are piling up too.

At any rate, a workaround for now:


$base = '/opt/puppetlabs/server'
exec { 'puppetserver-gem-install':
  command => "${base}/bin/puppetserver gem install hiera-eyaml",
  unless  => "test -f ${base}/data/puppetserver/jruby-gems/gems/hiera-eyaml-*/hiera-eyaml.gemspec >& /dev/null"
}
tkishel commented 4 years ago

The provider no longer starts a JVM to list gems, which addresses all but installation. For installing gems, its safest to use a JVM, so the system will require more memory.