sous-chefs / lvm

Development repository for the lvm cookbook
https://supermarket.chef.io/cookbooks/lvm
Apache License 2.0
56 stars 122 forks source link

cannot use **readahead** option #57

Open chrisduong opened 9 years ago

chrisduong commented 9 years ago

Hi,

I define an logical_volume as follow.

lvm_volume_group 'VG_01' do
  physical_volumes ['/dev/xvdf']

  logical_volume 'mongodb-data' do
    size        '100%VG'
    filesystem  'ext4'
    mount_point location: "#{node['mongodb']['config']['dbpath']}", options: 'defaults,auto,noatime,noexec'
    readahead 32
  end
end

But when chef run, it says No Method Error for NilClass

   ================================================================================
   Recipe Compile Error in /var/chef/cache/cookbooks/abcd/recipes/lvm_disks.rb
   ================================================================================

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

   Cookbook Trace:
   ---------------
     /var/chef/cache/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb:237:in `readahead'
     /var/chef/cache/cookbooks/abcd/recipes/lvm_disks.rb:68:in `block (2 levels) in from_file'
     /var/chef/cache/cookbooks/lvm/libraries/resource_lvm_volume_group.rb:110:in `logical_volume'
     /var/chef/cache/cookbooks/abcd/recipes/lvm_disks.rb:64:in `block in from_file'
     /var/chef/cache/cookbooks/abcd/recipes/lvm_disks.rb:61:in `from_file'

   Relevant File Content:
   ----------------------
   /var/chef/cache/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb:

   230:        # Attribute: readahead - the read ahead sector count of the logical volume
   231:        #
   232:        # @param arg [Integer, String] the read ahead sector count
   233:        #
   234:        # @return [Integer, String] the read ahead sector count
   235:        #
   236:        def readahead(arg = nil)
   237>>         set_or_return(
   238:            :readahead,
   239:            arg,
   240:            :kind_of => [Integer, String],
   241:            :equal_to => [2..120, 'auto', 'none'].flatten!
   242:          )
   243:        end
   244:
   245:        # Attribute: take_up_free_space - whether to have the LV take up the remainder of free space on the VG
   246:        #
matthewpick commented 6 years ago

This logic is definitely broken.

[2..120, 'auto', 'none'].flatten!

That should be:

[*2..120, 'auto', 'none']

However, why would there be an upper bound of 120 readahead size? Or is this the sector count, where each sector is typically 512kb?

A regex of some sort would better fit this problem.