Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LV Fails to create logical volumes with undefined method gsub #123

Closed
polliard-jmfe opened this issue Jan 24, 2017 · 9 comments
Closed

LV Fails to create logical volumes with undefined method gsub #123

polliard-jmfe opened this issue Jan 24, 2017 · 9 comments

Comments

@polliard-jmfe
Copy link

Cookbook version

4.0.5

Chef-client version

12.13.7

Platform Details

RHEL 7.2 AWS

Scenario:

Creating a VG Data with a Raw disk size of 10G. Calculating the remaining size of the disk from after 3 filesystems and creating a 4th with the remainder. The issue occurs long before that.

Steps to Reproduce:

The issue occurs during the first creation of an LV object.

      node['jmfe_elastic_cluster']['logical_volumes'].each do |key,lv|
        #log "KEY: #{key}:: #{node['jmfe_elastic_cluster']['logical_volumes'][key]['GBsize']}"
        size = node['jmfe_elastic_cluster']['logical_volumes'][key]['GBsize']
        path = node['jmfe_elastic_cluster']['logical_volumes'][key]['path']
        log "Size:#{size}G"
        log "Path:#{path}"

        lvm_logical_volume key do
           size "#{size}G"
           filesystem 'xfs'
           mount_point location: "#{path}, options: 'noatime,nodiratime'"
         end
      end

Expected Result:

4 Filesystems of the proper size to be created.

Actual Result:

       Recipe: jmfe_elastic_cluster::_configureLVM
         * lvm_physical_volume[/dev/xvdb] action create
           * chef_gem[/dev/xvdb_di-ruby-lvm-attrib_removal] action remove (up to date)
           * chef_gem[/dev/xvdb_di-ruby-lvm_removal] action remove (up to date)
            (up to date)
         * chef_gem[/dev/xvdb_di-ruby-lvm-attrib_removal] action remove (up to date)
         * chef_gem[/dev/xvdb_di-ruby-lvm_removal] action remove (up to date)
         * log[Size:1G] action write

         * log[Path:/var/log/elasticsearch] action write

         * lvm_logical_volume[elasticsearchlog] action create

           * chef_gem[elasticsearchlog_di-ruby-lvm-attrib_removal] action remove (up to date)
           * chef_gem[elasticsearchlog_di-ruby-lvm_removal] action remove (up to date)

           ================================================================================
           Error executing action `create` on resource 'lvm_logical_volume[elasticsearchlog]'
           ================================================================================

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

Cookbook Trace:
           ---------------
           /tmp/kitchen/cache/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb:287:in `to_dm_name'
           /tmp/kitchen/cache/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb:56:in `action_create'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:78:in `run_action'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block (2 levels) in converge'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `each'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block in converge'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:105:in `converge'

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/jmfe_elastic_cluster/recipes/_configureLVM.rb

            84:         lvm_logical_volume key do

            85:            size "#{size}G"
            86:            filesystem 'xfs'
            87:            mount_point location: "#{path}, options: 'noatime,nodiratime'"
            88:          end
            89:       end

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/jmfe_elastic_cluster/recipes/_configureLVM.rb:84:in `block (2 levels) in from_file'

           lvm_logical_volume("elasticsearchlog") do
             provider Chef::Provider::LvmLogicalVolume
             action :create
             retries 0
             retry_delay 2
             default_guard_interpreter :default
             declared_type :lvm_logical_volume
             cookbook_name "jmfe_elastic_cluster"
             recipe_name "_configureLVM"
             size "1G"
             filesystem "xfs"
             mount_point {:location=>"/var/log/elasticsearch, options: 'noatime,nodiratime'"}
           end


           Platform:
           ---------
           x86_64-linux


       Running handlers:
       [2017-01-24T09:59:27-05:00] ERROR: Running exception handlers
       Running handlers complete
       [2017-01-24T09:59:27-05:00] ERROR: Exception handlers complete
       Chef Client failed. 2 resources updated in 04 seconds
       [2017-01-24T09:59:27-05:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2017-01-24T09:59:27-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2017-01-24T09:59:27-05:00] ERROR: lvm_logical_volume[elasticsearchlog] (jmfe_elastic_cluster::_configureLVM line 84) had an error: NoMethodError: undefined method `gsub'
for nil:NilClass
       [2017-01-24T09:59:28-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
@polliard-jmfe
Copy link
Author

The attributes used were
default['jmfe_elastic_cluster']['logical_volume_group']['name'] = 'data' default['jmfe_elastic_cluster']['logical_volumes']['elasticsearchlog']['GBsize'] = 1 default['jmfe_elastic_cluster']['logical_volumes']['elasticsearchlog']['path'] = '/var/log/elasticsearch' default['jmfe_elastic_cluster']['logical_volumes']['elasticsearchlib']['GBsize'] = 1 default['jmfe_elastic_cluster']['logical_volumes']['elasticsearchlib']['path'] = '/var/lib/elasticsearch' default['jmfe_elastic_cluster']['logical_volumes']['elasticsearchcfg']['GBsize'] = 1 default['jmfe_elastic_cluster']['logical_volumes']['elasticsearchcfg']['path'] = '/etc/elasticsearch' default['jmfe_elastic_cluster']['logical_volumes']['elasticsearchshare']['GBsize'] = 1 default['jmfe_elastic_cluster']['logical_volumes']['elasticsearchshare']['path'] = '/usr/share/elasticsearch'

@polliard-jmfe polliard-jmfe changed the title LV Fails to create undefined method gsub LV Fails to create logical volumes with undefined method gsub Jan 24, 2017
@polliard-jmfe
Copy link
Author

I tried to hard set the the LV with the following
lvm_logical_volume 'elasticsearch-cfg' do size '1G' filesystem 'xfs' mount_point location: '/etc/elasticsearch', options: 'noatime,nodiratime' end

Doing that resulted in the EXACT same error. This is being run against a RHEL 7.2 system. Any ideas? Im pretty sure this is a bug. I did try to run it against the 4.0.4 version as well.

@MarkGibbons
Copy link
Member

MarkGibbons commented Jan 24, 2017

I think you need to specify a volume group.

group = new_resource.group
device_name = "/dev/mapper/#{to_dm_name(group)}-#{to_dm_name(name)}"

@polliard-jmfe
Copy link
Author

polliard-jmfe commented Jan 24, 2017 via email

@MarkGibbons
Copy link
Member

lvm_logical_volume key do
size "#{size}G"
filesystem 'xfs'
mount_point location: "#{path}, options: 'noatime,nodiratime'"
end

I still don't see it.

@polliard-jmfe
Copy link
Author

polliard-jmfe commented Jan 25, 2017 via email

@MarkGibbons
Copy link
Member

Just saying, rather than post the recipe, try specifying the the volume_group for the resource. Fixing "volume_group is not required" is in my back log of PRs to make against this product. It's a pretty well known problem.

@polliard-jmfe
Copy link
Author

I had the lvm_logical_volume within a lvm_volume_group block and didn't understand that you were stating to remove it from the block and just add the group option to the lvm_logical_volume resource. The reason the lvm_volume_group was not shown but I stated it was given was because it was in the outer block. As you stated, adding the group option to the lvm_logical_volume resource worked perfectly. Thanks again for the help.

@MarkGibbons
Copy link
Member

Cool.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants