Skip to content

Logical volumes with multiple extents report multiple times the same stripe size value #358

@jovandeginste

Description

@jovandeginste

Describe the Bug

When you have a logical volume with more than one extent (eg when you resize it after adding another logical volume), the command to report the stripe size gives a number per extent. While this should be the same number, this is still giving extra output.

/Stage[main]/Logical_volume[datavg-test]/stripes 	stripes changed "2\n     2" to 2 (corrective)

Expected Behavior

If all numbers reported are the same, report only this single number

Steps to Reproduce

  1. create a logical volume "test"
lvcreate -n test --size 10G --stripes 2 datavg
lvs -o stripes --noheadings /dev/datavg/test
     2
  1. create a second logical volume
  2. extend the first logical volume
lvcreate -n test --size 10G --stripes 2 datavg
lvs -o stripes --noheadings /dev/datavg/test
     2
     2

Environment

  • Version: 2.3.0
  • Platform: AlmaLinux 9.4

Additional Context

Fixed with:

  def stripes
    # Run the lvs command with the -o option to get only the stripes count
    raw = (lvs '-o', 'stripes', '--noheadings', path)

    output_array = raw.split(/\n/).map(&:strip).to_i

    return output_array.first if output_array.uniq.length == 1

    output_array
  end

  def stripes=(new_stripes_count)
    current_stripes = stripes

    # Changing stripes is not supported for existing logical volumes
    return unless new_stripes_count.to_i != current_stripes
    raise(Puppet::Error, "Changing stripes from #{current_stripes} to #{new_stripes_count} is not supported for existing logical volumes")
  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