afiune / test-kitchen

Test Kitchen is an integration tool for developing and testing infrastructure code and software on isolated target platforms.
http://kitchen.ci
Other
10 stars 7 forks source link

Mixlib::ShellOut commands keep dying with out of memory errors #17

Open docwhat opened 9 years ago

docwhat commented 9 years ago

Whenever Mixlib::ShellOut (e.g. the execute command in a recipe) is used, the executed process runs out of memory.

The cookbooks I'm using have only done chef-service-manager and gem (from 'chef-sugar') and both are ruby commands. So I don't know if it is a ruby-specific problem or not.

It's very odd because the commands run fine by hand as Administrator.

Ciao!

Example:

================================================================================
       Error executing action `run` on resource 'execute[register-chef-service]'
       ================================================================================

       Mixlib::ShellOut::ShellCommandFailed
       ------------------------------------
       Expected process to exit with [0], but received '1'
       ---- Begin output of chef-service-manager -a install ----
       STDOUT:
       STDERR: C:/opscode/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require': failed to allocate memory (NoMemoryError)
        from C:/opscode/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
        from C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/provider/service/windows.rb:24:in `<top (required)>'
        from C:/opscode/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
        from C:/opscode/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
        from C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/providers.rb:85:in `<top (required)>'
        from C:/opscode/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
        from C:/opscode/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
        from C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef.rb:25:in `<top (required)>'
        from C:/opscode/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
        from C:/opscode/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
        from C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/bin/chef-service-manager:23:in `<top (required)>'
        from C:/opscode/chef/bin/chef-service-manager:23:in `load'
        from C:/opscode/chef/bin/chef-service-manager:23:in `<main>'
       ---- End output of chef-service-manager -a install ----
       Ran chef-service-manager -a install returned 1
robcoward commented 9 years ago

You don't mention it, but I'm guessing that this is occurring in a winrm session to a windows guest ? If so, you might want to check out https://support.microsoft.com/kb/2842230

docwhat commented 9 years ago

Switching from chef_zero to chef_solo seemed to fix it. I'm not sure why, though.

docwhat commented 9 years ago

@robcoward Yes, it is a winrm session to a windows guest. That's lovely that winrm has such a hard limit. I'm guessing chef_zero is using a lot more memory because it emulates a whole chef-server and chef-client?

Is there a way a separate session can be run that honors the MaxMemoryPerShellMB value from winrm? Or maybe a service should be created for chef_zero/chef_solo and it run manually by winrm?

That would work around most/all the cases, no?

robcoward commented 9 years ago

Our solution was to use packer to create our own custom vagrant box file and AWS ami with the microsoft patch applied. Once the patch is applied to your vm, the memory errors go away.