Browse Source

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 0b9e76f280)

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
John Griffith 4 years ago
parent
commit
4bf861c76c
4 changed files with 34 additions and 48 deletions
  1. 0
    17
      lib/cinder
  2. 0
    31
      lib/cinder_backends/lvm
  3. 25
    0
      lib/lvm
  4. 9
    0
      stack.sh

+ 0
- 17
lib/cinder View File

@@ -372,15 +372,9 @@ function init_cinder {
372 372
 
373 373
     if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
374 374
         local be be_name be_type
375
-        local has_lvm=0
376 375
         for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
377 376
             be_type=${be%%:*}
378 377
             be_name=${be##*:}
379
-
380
-            if [[ $be_type == 'lvm' ]]; then
381
-                has_lvm=1
382
-            fi
383
-
384 378
             if type init_cinder_backend_${be_type} >/dev/null 2>&1; then
385 379
                 # Always init the default volume group for lvm.
386 380
                 if [[ "$be_type" == "lvm" ]]; then
@@ -391,17 +385,6 @@ function init_cinder {
391 385
         done
392 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 388
     mkdir -p $CINDER_STATE_PATH/volumes
406 389
     create_cinder_cache_dir
407 390
 }

+ 0
- 31
lib/cinder_backends/lvm View File

@@ -19,7 +19,6 @@
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()
23 22
 
24 23
 
25 24
 # Save trace setting
@@ -66,36 +65,6 @@ function init_cinder_backend_lvm {
66 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
71
-function 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 68
 # Restore xtrace
100 69
 $MY_XTRACE
101 70
 

+ 25
- 0
lib/lvm View File

@@ -138,6 +138,31 @@ function init_default_lvm_volume_group {
138 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()
149
+function 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 167
 # Restore xtrace
143 168
 $MY_XTRACE

+ 9
- 0
stack.sh View File

@@ -1316,6 +1316,15 @@ service_check
1316 1316
 # Prepare bash completion for OSC
1317 1317
 openstack 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
1320
+if 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
1327
+fi
1319 1328
 
1320 1329
 # Fin
1321 1330
 # ===

Loading…
Cancel
Save