Skip to content

BUG: physical_volume fact pv_size and dev_size produce same key #373

@schlitzered

Description

@schlitzered

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

  1. Run the facter for physical_volumes on a Linux system with LVM and physical volumes present.
  2. Observe the output for the physical_volumes fact.
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions