Skip to content

followsymlinks is not honored in volume_group provider #375

@cruelsmith

Description

@cruelsmith

Describe the Bug

The parameter followsymlinks of volume_group is only honored in the type but not in the provider.
In the case the VG is out of sync the provider tries to remove all symlink targets even when the provided symlink points to them.

Expected Behavior

vgextend and vgreduce feature works with provided symlinks like /dev/disk/by-path/* when followsymlinks => true has been provided.

Steps to Reproduce

  • initial hiera data:
lvm::volume_groups:
  vgdata:
    ensure: present
    followsymlinks: true
    physical_volumes:
      - "/dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:1:0"
      - "/dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:2:0"
  • inital puppet run
  • change hiera data
lvm::volume_groups:
  vgdata:
    ensure: present
    followsymlinks: true
    physical_volumes:
      - '/dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:1:0'
      - '/dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:2:0'
      - '/dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:3:0'
  • Puppet run:

Volume_group[vgdata]/physical_volumes

change from ['/dev/sdb', '/dev/sdc'] to ['/dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:1:0', '/dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:2:0', '/dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:3:0'] failed: Could not remove physical volume /dev/sdb from volume group 'vgdata'; this physical volume may be in use and may require a manual data migration (using pvmove) before it can be removed (Execution of '/sbin/vgreduce vgdata /dev/sdb' returned 5:

Physical volume "/dev/sdb" still in use)

Environment

  • Version 3.0.1
  • Platform RHEL 9

Additional Context

One possible fix would be to apply the same symlink follow logic from

if @resource.parameter(:followsymlinks).value == :true
real_should = []
real_is = []
should.each do |s|
if File.symlink?(s)
device = File.expand_path(File.readlink(s), File.dirname(s))
debug("resolved symlink '#{s}' to device '#{device}'")
real_should.push device
else
real_should.push s
end
end
is.each do |s|
if File.symlink?(s)
device = File.expand_path(File.readlink(s), File.dirname(s))
debug("resolved symlink '#{s}' to device '#{device}'")
real_is.push device
else
real_is.push s
end
end
to
existing_volumes = physical_volumes
extraneous = existing_volumes - new_volumes
extraneous.each { |volume| reduce_with(volume) }
missing = new_volumes - existing_volumes
missing.each { |volume| extend_with(volume) }
before the extraneous and missing diff happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions