0b9e76f280
We have a number of issues where LVM scan commands hang during test runs. Looking closer at this with strace it turns out that what seems to be happening is that we're scanning all of the devices on the node, this includes the loop devices for swift and other projects as well as the Cinder devices that are being attached to the system during the test. This is particularly messy for example when we issue a VG or LV scan on a device like /dev/vdb and at the same time issue a detach. The result is LVM scan commands hanging waiting for timeout. This patch adds a function to the cinder_backend/lvm module which is called as the last part of cinder init. If Cinder LVM is in use as per cinder.conf this function will copy the default /etc/lvm/lvm.conf to /etc/cinder/lvm.conf and use the cinder.conf file and PVS to create filters so that ONLY the devices actually being used by Cinder are included in scans. There are two pieces to this fix; the first is to properly setup an lvm.conf file with filters. The second step is to merge the Cinder change that modifies the Cinder LVM commands to specify the lvm.conf file usage. The Cinder part of this fix can be found here: https://review.openstack.org/#/c/148747/ Change-Id: I962b6e21cbfb6f5612b6c973053d86828ca8071a Partial-Bug: #1373513
102 lines
3.0 KiB
Bash
102 lines
3.0 KiB
Bash
#!/bin/bash
|
|
#
|
|
# lib/cinder_backends/lvm
|
|
# Configure the LVM backend
|
|
|
|
# Enable with:
|
|
#
|
|
# CINDER_ENABLED_BACKENDS+=,lvm:lvmname
|
|
|
|
# Dependencies:
|
|
#
|
|
# - ``functions`` file
|
|
# - ``cinder`` configurations
|
|
|
|
# CINDER_CONF
|
|
# DATA_DIR
|
|
# VOLUME_GROUP_NAME
|
|
|
|
# clean_cinder_backend_lvm - called from clean_cinder()
|
|
# configure_cinder_backend_lvm - called from configure_cinder()
|
|
# init_cinder_backend_lvm - called from init_cinder()
|
|
# configure_cinder_backend_conf_lvm - called from configure_cinder()
|
|
|
|
|
|
# Save trace setting
|
|
MY_XTRACE=$(set +o | grep xtrace)
|
|
set +o xtrace
|
|
|
|
|
|
# TODO: resurrect backing device...need to know how to set values
|
|
#VOLUME_BACKING_DEVICE=${VOLUME_BACKING_DEVICE:-}
|
|
|
|
# Entry Points
|
|
# ------------
|
|
|
|
# cleanup_cinder_backend_lvm - Delete volume group and remove backing file
|
|
# cleanup_cinder_backend_lvm $be_name
|
|
function cleanup_cinder_backend_lvm {
|
|
local be_name=$1
|
|
|
|
# Campsite rule: leave behind a volume group at least as clean as we found it
|
|
clean_lvm_volume_group $VOLUME_GROUP_NAME-$be_name
|
|
}
|
|
|
|
# configure_cinder_backend_lvm - Set config files, create data dirs, etc
|
|
# configure_cinder_backend_lvm $be_name
|
|
function configure_cinder_backend_lvm {
|
|
local be_name=$1
|
|
|
|
iniset $CINDER_CONF $be_name volume_backend_name $be_name
|
|
iniset $CINDER_CONF $be_name volume_driver "cinder.volume.drivers.lvm.LVMISCSIDriver"
|
|
iniset $CINDER_CONF $be_name volume_group $VOLUME_GROUP_NAME-$be_name
|
|
|
|
if [[ "$CINDER_SECURE_DELETE" == "False" ]]; then
|
|
iniset $CINDER_CONF $be_name volume_clear none
|
|
fi
|
|
}
|
|
|
|
# init_cinder_backend_lvm - Initialize volume group
|
|
# init_cinder_backend_lvm $be_name
|
|
function init_cinder_backend_lvm {
|
|
local be_name=$1
|
|
|
|
# Start with a clean volume group
|
|
init_lvm_volume_group $VOLUME_GROUP_NAME-$be_name $VOLUME_BACKING_FILE_SIZE
|
|
}
|
|
|
|
# configure_cinder_backend_conf_lvm - Sets device filter in /etc/cinder/lvm.conf
|
|
# init_cinder_backend_lvm
|
|
function configure_cinder_backend_conf_lvm {
|
|
local filter_suffix='"r/.*/" ]'
|
|
local filter_string="filter = [ "
|
|
local conf_entries=$(grep volume_group /etc/cinder/cinder.conf | sed "s/ //g")
|
|
local pv
|
|
local vg
|
|
local line
|
|
|
|
for pv_info in $(sudo pvs --noheadings -o name,vg_name --separator ';'); do
|
|
IFS=';' read pv vg <<< $pv_info
|
|
for line in ${conf_entries}; do
|
|
IFS='=' read label group <<< $line
|
|
group=$(echo $group|sed "s/^ *//g")
|
|
if [[ "$vg" == "$group" ]]; then
|
|
new="\"a$pv/\", "
|
|
filter_string=$filter_string$new
|
|
fi
|
|
done
|
|
done
|
|
filter_string=$filter_string$filter_suffix
|
|
|
|
# FIXME(jdg): Possible odd case that the lvm.conf file has been modified
|
|
# and doesn't have a filter entry to search/replace. For devstack don't
|
|
# know that we care, but could consider adding a check and add
|
|
sudo sed -i "s#^[ \t]*filter.*# $filter_string#g" /etc/cinder/lvm.conf
|
|
echo "set LVM filter_strings: $filter_string"
|
|
}
|
|
# Restore xtrace
|
|
$MY_XTRACE
|
|
|
|
# mode: shell-script
|
|
# End:
|