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
... | ... |
@@ -395,15 +395,32 @@ function init_cinder { |
395 | 395 |
|
396 | 396 |
if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then |
397 | 397 |
local be be_name be_type |
398 |
+ local has_lvm=0 |
|
398 | 399 |
for be in ${CINDER_ENABLED_BACKENDS//,/ }; do |
399 | 400 |
be_type=${be%%:*} |
400 | 401 |
be_name=${be##*:} |
402 |
+ |
|
403 |
+ if [[ $be_type == 'lvm' ]]; then |
|
404 |
+ has_lvm=1 |
|
405 |
+ fi |
|
406 |
+ |
|
401 | 407 |
if type init_cinder_backend_${be_type} >/dev/null 2>&1; then |
402 | 408 |
init_cinder_backend_${be_type} ${be_name} |
403 | 409 |
fi |
404 | 410 |
done |
405 | 411 |
fi |
406 | 412 |
|
413 |
+ # Keep it simple, set a marker if there's an LVM backend |
|
414 |
+ # use the created VG's to setup lvm filters |
|
415 |
+ if [[ $has_lvm == 1 ]]; then |
|
416 |
+ # Order matters here, not only obviously to make |
|
417 |
+ # sure the VG's are created, but also some distros |
|
418 |
+ # do some customizations to lvm.conf on init, we |
|
419 |
+ # want to make sure we copy those over |
|
420 |
+ sudo cp /etc/lvm/lvm.conf /etc/cinder/lvm.conf |
|
421 |
+ configure_cinder_backend_conf_lvm |
|
422 |
+ fi |
|
423 |
+ |
|
407 | 424 |
mkdir -p $CINDER_STATE_PATH/volumes |
408 | 425 |
create_cinder_cache_dir |
409 | 426 |
} |
... | ... |
@@ -19,6 +19,7 @@ |
19 | 19 |
# clean_cinder_backend_lvm - called from clean_cinder() |
20 | 20 |
# configure_cinder_backend_lvm - called from configure_cinder() |
21 | 21 |
# init_cinder_backend_lvm - called from init_cinder() |
22 |
+# configure_cinder_backend_conf_lvm - called from configure_cinder() |
|
22 | 23 |
|
23 | 24 |
|
24 | 25 |
# Save trace setting |
... | ... |
@@ -64,6 +65,35 @@ function init_cinder_backend_lvm { |
64 | 64 |
init_lvm_volume_group $VOLUME_GROUP_NAME-$be_name $VOLUME_BACKING_FILE_SIZE |
65 | 65 |
} |
66 | 66 |
|
67 |
+# configure_cinder_backend_conf_lvm - Sets device filter in /etc/cinder/lvm.conf |
|
68 |
+# init_cinder_backend_lvm |
|
69 |
+function configure_cinder_backend_conf_lvm { |
|
70 |
+ local filter_suffix='"r/.*/" ]' |
|
71 |
+ local filter_string="filter = [ " |
|
72 |
+ local conf_entries=$(grep volume_group /etc/cinder/cinder.conf | sed "s/ //g") |
|
73 |
+ local pv |
|
74 |
+ local vg |
|
75 |
+ local line |
|
76 |
+ |
|
77 |
+ for pv_info in $(sudo pvs --noheadings -o name,vg_name --separator ';'); do |
|
78 |
+ IFS=';' read pv vg <<< $pv_info |
|
79 |
+ for line in ${conf_entries}; do |
|
80 |
+ IFS='=' read label group <<< $line |
|
81 |
+ group=$(echo $group|sed "s/^ *//g") |
|
82 |
+ if [[ "$vg" == "$group" ]]; then |
|
83 |
+ new="\"a$pv/\", " |
|
84 |
+ filter_string=$filter_string$new |
|
85 |
+ fi |
|
86 |
+ done |
|
87 |
+ done |
|
88 |
+ filter_string=$filter_string$filter_suffix |
|
89 |
+ |
|
90 |
+ # FIXME(jdg): Possible odd case that the lvm.conf file has been modified |
|
91 |
+ # and doesn't have a filter entry to search/replace. For devstack don't |
|
92 |
+ # know that we care, but could consider adding a check and add |
|
93 |
+ sudo sed -i "s#^[ \t]*filter.*# $filter_string#g" /etc/cinder/lvm.conf |
|
94 |
+ echo "set LVM filter_strings: $filter_string" |
|
95 |
+} |
|
67 | 96 |
# Restore xtrace |
68 | 97 |
$MY_XTRACE |
69 | 98 |
|