Enable filtering for Cinder LVM volumes

Currently the default behavior of LVM is
to scan all available block devices in
/dev folder, this leads to issues on environments
with Cinder LVM volumes. Guest's volumes are recognized
by parent host's OS and are scanned by LVM. If guest's
volume contains LVM inside, it is also detected by
parent host's OS. Such volumes can not be
deleted.

This patch modifies LVM filter on Cinder node in
order to exclude LVs present in Cinder volume group
from LVM scan. During testing it was found that
initramds should be updated upon changing of filtering
rules.

Change-Id: I49e286e92095259e0196b6dd49dc10da0ebb4c20
Closes-Bug: #1645624
(backported from commit fea0daea1b)
This commit is contained in:
Mykyta Karpin 2016-12-12 17:33:31 +02:00 committed by Sergii Rizvan
parent 5ca8cf49d6
commit a0fa57c999
2 changed files with 39 additions and 0 deletions

View File

@ -2,6 +2,7 @@ notice('MODULAR: cinder.pp')
# Pulling hiera
prepare_network_config(hiera('network_scheme', {}))
$volume_group = hiera('cinder_volume_group', 'cinder')
$storage_address = get_network_role_property('cinder/iscsi', 'ipaddr')
$public_vip = hiera('public_vip')
$management_vip = hiera('management_vip')
@ -134,6 +135,23 @@ $idle_timeout = '3600'
if (member($roles, 'cinder') and $storage_hash['volumes_lvm']) {
$manage_volumes = 'iscsi'
$cinder_lvm_filter = "\"r|^/dev/${volume_group}/.*|\""
file_line { 'lvm-conf-set-cinder-filter':
ensure => present,
path => '/etc/lvm/lvm.conf',
line => "global_filter = ${cinder_lvm_filter}",
match => 'global_filter\ \=\ ',
tag => 'lvm-conf-file-line'
}
exec { 'Update initramfs':
command => 'update-initramfs -u -k all',
path => '/usr/bin:/bin:/usr/sbin:/sbin',
refreshonly => true,
}
File_line<| tag == 'lvm-conf-file-line'|> ~> Exec<| title == 'Update initramfs' |>
} elsif (member($roles, 'cinder') and $storage_hash['volumes_vmdk']) {
$manage_volumes = 'vmdk'
} elsif ($storage_hash['volumes_ceph']) {

View File

@ -6,6 +6,27 @@ describe manifest do
shared_examples 'catalog' do
storage_hash = Noop.hiera 'storage'
volume_group = Noop.hiera('cinder_volume_group', 'cinder')
if storage_hash['volumes_lvm']
it 'sets up filtering for LVM Cinder volumes' do
cinder_lvm_filter = "\"r|^/dev/#{volume_group}/.*|\""
should contain_file_line('lvm-conf-set-cinder-filter').with(
'ensure' => 'present',
'path' => '/etc/lvm/lvm.conf',
'line' => "global_filter = #{cinder_lvm_filter}",
'match' => 'global_filter\ \=\ ',
'tag' => 'lvm-conf-file-line'
).that_notifies('Exec[Update initramfs]')
should contain_exec('Update initramfs').with(
'command' => 'update-initramfs -u -k all',
'path' => '/usr/bin:/bin:/usr/sbin:/sbin',
'refreshonly' => 'true')
end
end
if Noop.hiera 'use_ceph' and !(storage_hash['volumes_lvm'])
it { should contain_class('ceph') }