Skip to content

Server recipe fails due to undefined method `*' for nil:NilClass #8

@runningman84

Description

@runningman84

My lxc container looks fine:

Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-68-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
Last login: Thu Nov 26 10:27:42 2015 from 10.0.3.1
vagrant@default-ubuntu-1404:~$ free
             total       used       free     shared    buffers     cached
Mem:       8176980    5876132    2300848      67664     334620    4226132
-/+ buffers/cache:    1315380    6861600
Swap:      1046524          0    1046524

But the recipe has problems with the memory calculation:

================================================================================
         Recipe Compile Error in /tmp/kitchen/cache/cookbooks/postgres/recipes/server.rb
         ================================================================================

         NoMethodError
         -------------
         undefined method `*' for nil:NilClass

         Cookbook Trace:
         ---------------
           /tmp/kitchen/cache/cookbooks/postgres/recipes/server.rb:33:in `from_file'

         Relevant File Content:
         ----------------------
         /tmp/kitchen/cache/cookbooks/postgres/recipes/server.rb:

          26:    when 'smartos'
          27:      available_ram = `prtconf -m`.chomp.to_i
          28:    when 'linux'
          29:      free_bytes = `free | grep Mem | awk '{print $2}'`.chomp.to_i  # in Kb
          30:      available_ram = free_bytes / 1024 # in Mb
          31:  end
          32:  
          33>> shared_buffers_mb       = [12000, (available_ram * 0.25).to_i].min
          34:  effective_cache_size_mb = (available_ram * 0.95).to_i - shared_buffers_mb
          35:  
          36:  node.default['postgres']['config']['shared_buffers_mb']       = shared_buffers_mb
          37:  node.default['postgres']['config']['effective_cache_size_mb'] = effective_cache_size_mb
          38:  
          39:  version       = node['postgres']['version']                # eg 9.2.1
          40:  version_abbr  = version.split('.').slice(0..1).join        # eg 92
          41:  version_num   = version.split('.').join                    # eg 921
          42:  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions