summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Griffith <john.griffith@solidfire.com>2015-03-17 21:07:39 -0600
committerJohn Griffith <john.griffith@solidfire.com>2015-03-18 10:29:29 -0600
commit4bf861c76c220a98a3b3165eea5448411d000f3a (patch)
tree3456436ad5a89e384fb206c36557ff88c6279907
parent5e159edab375ed950cc5c91a6c445bbc5541b3c1 (diff)
Create global_filter to avoid scan of missing devs
A while back I added an lvm.conf file with a device filter setting to try and clean up the LVM hangs in the gate: (commit 0b9e76f280208b5b5ad54bb6fbc4133e63037286) It turns out this wasn't the real problem, the real problem is that on an LVS/VGS command LVM will attempt to open and read all potential block devices in /dev to see if they have LVM data on them. I initially thought the local filter would keep that from happening, as it turns out the local filter only limits what's returned AFTER the actual scan process. In order to keep the scan from happening at all, either a global_filter needs to be used or lvmetad needs to be running and enabled. There are situations in gate tests where /dev/sdX devices are created and deleted and the result is that we hit situations where LVM tries to open up devices to check them even if they've been removed. The result is we have a blocking open call from LVM that takes approx 60 seconds to time out and fail. Ubuntu won't have a version of lvmetad until Vivid, so for now that just leaves the global_filter as an option. This patch adds the filter routine to the end of stack.sh. We don't want to put the routine in lib/cinder_backend/lvm like we had it because now we have to set the global filter for all LVM commands on the system. So we put this as one of the last steps in stack.sh and run it if Cinder is enabled. This way we can query PV's on the system regardless of what other services may be running and using LVM and make sure that all of their devices are added to the filter as well. Also, make sure we only set this for Ubuntu as Fedora/RHEL variants utilize lvmetad. This patch also removes the old change that set the local filter. DocImpact Should add this to recommended config for Cinder on systems that don't have lvmetad, and recommend lvmetad for those that do. Change-Id: I5d5c48e188cbb9b4208096736807f082bce524e8 Closes-Bug: #1373513
Notes
Notes (review): Verified+2: Jenkins Code-Review+2: Dean Troyer <dtroyer@gmail.com> Code-Review+1: Joe Gordon <joe.gordon0@gmail.com> Code-Review+2: Matthew Treinish <mtreinish@kortar.org> Workflow+1: Matthew Treinish <mtreinish@kortar.org> Verified+1: Citrix XenServer CI Submitted-by: Jenkins Submitted-at: Wed, 18 Mar 2015 23:43:27 +0000 Reviewed-on: https://review.openstack.org/165281 Project: openstack-dev/devstack Branch: refs/heads/master
-rw-r--r--lib/cinder17
-rw-r--r--lib/cinder_backends/lvm31
-rw-r--r--lib/lvm25
-rwxr-xr-xstack.sh9
4 files changed, 34 insertions, 48 deletions
diff --git a/lib/cinder b/lib/cinder
index 880af1f..958c7f0 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -372,15 +372,9 @@ function init_cinder {
372 372
373 if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then 373 if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
374 local be be_name be_type 374 local be be_name be_type
375 local has_lvm=0
376 for be in ${CINDER_ENABLED_BACKENDS//,/ }; do 375 for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
377 be_type=${be%%:*} 376 be_type=${be%%:*}
378 be_name=${be##*:} 377 be_name=${be##*:}
379
380 if [[ $be_type == 'lvm' ]]; then
381 has_lvm=1
382 fi
383
384 if type init_cinder_backend_${be_type} >/dev/null 2>&1; then 378 if type init_cinder_backend_${be_type} >/dev/null 2>&1; then
385 # Always init the default volume group for lvm. 379 # Always init the default volume group for lvm.
386 if [[ "$be_type" == "lvm" ]]; then 380 if [[ "$be_type" == "lvm" ]]; then
@@ -391,17 +385,6 @@ function init_cinder {
391 done 385 done
392 fi 386 fi
393 387
394 # Keep it simple, set a marker if there's an LVM backend
395 # use the created VG's to setup lvm filters
396 if [[ $has_lvm == 1 ]]; then
397 # Order matters here, not only obviously to make
398 # sure the VG's are created, but also some distros
399 # do some customizations to lvm.conf on init, we
400 # want to make sure we copy those over
401 sudo cp /etc/lvm/lvm.conf /etc/cinder/lvm.conf
402 configure_cinder_backend_conf_lvm
403 fi
404
405 mkdir -p $CINDER_STATE_PATH/volumes 388 mkdir -p $CINDER_STATE_PATH/volumes
406 create_cinder_cache_dir 389 create_cinder_cache_dir
407} 390}
diff --git a/lib/cinder_backends/lvm b/lib/cinder_backends/lvm
index 52fc6fb..f210578 100644
--- a/lib/cinder_backends/lvm
+++ b/lib/cinder_backends/lvm
@@ -19,7 +19,6 @@
19# clean_cinder_backend_lvm - called from clean_cinder() 19# clean_cinder_backend_lvm - called from clean_cinder()
20# configure_cinder_backend_lvm - called from configure_cinder() 20# configure_cinder_backend_lvm - called from configure_cinder()
21# init_cinder_backend_lvm - called from init_cinder() 21# init_cinder_backend_lvm - called from init_cinder()
22# configure_cinder_backend_conf_lvm - called from configure_cinder()
23 22
24 23
25# Save trace setting 24# Save trace setting
@@ -66,36 +65,6 @@ function init_cinder_backend_lvm {
66 init_lvm_volume_group $VOLUME_GROUP_NAME-$be_name $VOLUME_BACKING_FILE_SIZE 65 init_lvm_volume_group $VOLUME_GROUP_NAME-$be_name $VOLUME_BACKING_FILE_SIZE
67} 66}
68 67
69# configure_cinder_backend_conf_lvm - Sets device filter in /etc/cinder/lvm.conf
70# init_cinder_backend_lvm
71function configure_cinder_backend_conf_lvm {
72 local filter_suffix='"r/.*/" ]'
73 local filter_string="filter = [ "
74 local conf_entries=$(grep volume_group /etc/cinder/cinder.conf | sed "s/ //g")
75 local pv
76 local vg
77 local line
78
79 for pv_info in $(sudo pvs --noheadings -o name,vg_name --separator ';'); do
80 echo_summary "Evaluate PV info for Cinder lvm.conf: $pv_info"
81 IFS=';' read pv vg <<< "$pv_info"
82 for line in ${conf_entries}; do
83 IFS='=' read label group <<< "$line"
84 group=$(echo $group|sed "s/^ *//g")
85 if [[ "$vg" == "$group" ]]; then
86 new="\"a$pv/\", "
87 filter_string=$filter_string$new
88 fi
89 done
90 done
91 filter_string=$filter_string$filter_suffix
92
93 # FIXME(jdg): Possible odd case that the lvm.conf file has been modified
94 # and doesn't have a filter entry to search/replace. For devstack don't
95 # know that we care, but could consider adding a check and add
96 sudo sed -i "s#^[ \t]*filter.*# $filter_string#g" /etc/cinder/lvm.conf
97 echo "set LVM filter_strings: $filter_string"
98}
99# Restore xtrace 68# Restore xtrace
100$MY_XTRACE 69$MY_XTRACE
101 70
diff --git a/lib/lvm b/lib/lvm
index 39eed00..d0322c7 100644
--- a/lib/lvm
+++ b/lib/lvm
@@ -138,6 +138,31 @@ function init_default_lvm_volume_group {
138 fi 138 fi
139} 139}
140 140
141# set_lvm_filter() Gather all devices configured for LVM and
142# use them to build a global device filter
143# set_lvm_filter() Create a device filter
144# and add to /etc/lvm.conf. Note this uses
145# all current PV's in use by LVM on the
146# system to build it's filter.
147#
148# Usage: set_lvm_filter()
149function set_lvm_filter {
150 local filter_suffix='"r|.*|" ]'
151 local filter_string="global_filter = [ "
152 local pv
153 local vg
154 local line
155
156 for pv_info in $(sudo pvs --noheadings -o name); do
157 pv=$(echo -e "${pv_info}" | sed 's/ //g' | sed 's/\/dev\///g')
158 new="\"a|$pv|\", "
159 filter_string=$filter_string$new
160 done
161 filter_string=$filter_string$filter_suffix
162
163 sudo sed -i "/# global_filter = \[*\]/a\ $global_filter$filter_string" /etc/lvm/lvm.conf
164 echo_summary "set lvm.conf device global_filter to: $filter_string"
165}
141 166
142# Restore xtrace 167# Restore xtrace
143$MY_XTRACE 168$MY_XTRACE
diff --git a/stack.sh b/stack.sh
index eac7eec..ee1b985 100755
--- a/stack.sh
+++ b/stack.sh
@@ -1316,6 +1316,15 @@ service_check
1316# Prepare bash completion for OSC 1316# Prepare bash completion for OSC
1317openstack complete | sudo tee /etc/bash_completion.d/osc.bash_completion > /dev/null 1317openstack complete | sudo tee /etc/bash_completion.d/osc.bash_completion > /dev/null
1318 1318
1319# If cinder is configured, set global_filter for PV devices
1320if is_service_enabled cinder; then
1321 if is_ubuntu; then
1322 echo_summary "Configuring lvm.conf global device filter"
1323 set_lvm_filter
1324 else
1325 echo_summary "Skip setting lvm filters for non Ubuntu systems"
1326 fi
1327fi
1319 1328
1320# Fin 1329# Fin
1321# === 1330# ===