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
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'
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.
Describe the Bug
The parameter
followsymlinksofvolume_groupis 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/*whenfollowsymlinks => truehas been provided.Steps to Reproduce
Environment
Additional Context
One possible fix would be to apply the same symlink follow logic from
puppetlabs-lvm/lib/puppet/type/volume_group.rb
Lines 23 to 43 in e1c93fd
puppetlabs-lvm/lib/puppet/provider/volume_group/lvm.rb
Lines 71 to 75 in e1c93fd
extraneousandmissingdiff happens.