Describe the Bug
The parse function in lib/puppet_x/lvm/output.rb removes any prefix before the first _ in column names. This causes columns like pv_size and dev_size to both become size, resulting in key collisions and data loss in the parsed output.
Expected Behavior
Each column should retain a unique key in the parsed output, so values from pv_size and dev_size are both available and not overwritten.
Steps to Reproduce
- Run the facter for
physical_volumes on a Linux system with LVM and physical volumes present.
- Observe the output for the
physical_volumes fact.
- Notice that only one value for
size is present, instead of both pv_size and dev_size.
Environment
- Version: [e.g. 1.27.0]
- Platform: [e.g. Ubuntu 18.04]
Additional Context
This issue affects any columns with similar suffixes after the prefix, leading to loss of important data in the fact output.
Suggested Solution
Update the remove_prefix method in lib/puppet_x/lvm/output.rb to handle dev_size as a special case, converting it to devsize. This will retain the old behavior for pv_size (which becomes size), since pv_size is defined after dev_size in the columns array.
def self.remove_prefix(item)
return item if item == 'dev_size'
item.gsub(%r{^[A-Za-z]+_}, '')
end
Describe the Bug
The
parsefunction inlib/puppet_x/lvm/output.rbremoves any prefix before the first_in column names. This causes columns likepv_sizeanddev_sizeto both becomesize, resulting in key collisions and data loss in the parsed output.Expected Behavior
Each column should retain a unique key in the parsed output, so values from
pv_sizeanddev_sizeare both available and not overwritten.Steps to Reproduce
physical_volumeson a Linux system with LVM and physical volumes present.physical_volumesfact.sizeis present, instead of bothpv_sizeanddev_size.Environment
Additional Context
This issue affects any columns with similar suffixes after the prefix, leading to loss of important data in the fact output.
Suggested Solution
Update the
remove_prefixmethod inlib/puppet_x/lvm/output.rbto handledev_sizeas a special case, converting it todevsize. This will retain the old behavior forpv_size(which becomessize), sincepv_sizeis defined afterdev_sizein the columns array.