Removing the cinder volume group breaks devstack installations
that share that volume group with other logical volumes. It also was
leaking loopback devices.
Change-Id: Ice4470e06e08ce49a0e1f82af70abcc015c91c20
... | ... |
@@ -48,6 +48,20 @@ fi |
48 | 48 |
VOLUME_GROUP=${VOLUME_GROUP:-stack-volumes} |
49 | 49 |
VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-} |
50 | 50 |
|
51 |
+# _clean_volume_group removes all cinder volumes from the specified volume group |
|
52 |
+# _clean_volume_group $VOLUME_GROUP $VOLUME_NAME_PREFIX |
|
53 |
+function _clean_volume_group() { |
|
54 |
+ local vg=$1 |
|
55 |
+ local vg_prefix=$2 |
|
56 |
+ # Clean out existing volumes |
|
57 |
+ for lv in `sudo lvs --noheadings -o lv_name $vg`; do |
|
58 |
+ # vg_prefix prefixes the LVs we want |
|
59 |
+ if [[ "${lv#$vg_prefix}" != "$lv" ]]; then |
|
60 |
+ sudo lvremove -f $vg/$lv |
|
61 |
+ fi |
|
62 |
+ done |
|
63 |
+} |
|
64 |
+ |
|
51 | 65 |
# cleanup_cinder() - Remove residual data files, anything left over from previous |
52 | 66 |
# runs that a clean run would need to clean up |
53 | 67 |
function cleanup_cinder() { |
... | ... |
@@ -84,7 +98,8 @@ function cleanup_cinder() { |
84 | 84 |
stop_service tgtd |
85 | 85 |
fi |
86 | 86 |
|
87 |
- sudo vgremove -f $VOLUME_GROUP |
|
87 |
+ # Campsite rule: leave behind a volume group at least as clean as we found it |
|
88 |
+ _clean_volume_group $VOLUME_GROUP $VOLUME_NAME_PREFIX |
|
88 | 89 |
} |
89 | 90 |
|
90 | 91 |
# configure_cinder() - Set config files, create data dirs, etc |
... | ... |
@@ -272,13 +287,8 @@ function init_cinder() { |
272 | 272 |
|
273 | 273 |
# Remove iscsi targets |
274 | 274 |
sudo tgtadm --op show --mode target | grep $VOLUME_NAME_PREFIX | grep Target | cut -f3 -d ' ' | sudo xargs -n1 tgt-admin --delete || true |
275 |
- # Clean out existing volumes |
|
276 |
- for lv in `sudo lvs --noheadings -o lv_name $VOLUME_GROUP`; do |
|
277 |
- # VOLUME_NAME_PREFIX prefixes the LVs we want |
|
278 |
- if [[ "${lv#$VOLUME_NAME_PREFIX}" != "$lv" ]]; then |
|
279 |
- sudo lvremove -f $VOLUME_GROUP/$lv |
|
280 |
- fi |
|
281 |
- done |
|
275 |
+ # Start with a clean volume group |
|
276 |
+ _clean_volume_group $VOLUME_GROUP $VOLUME_NAME_PREFIX |
|
282 | 277 |
fi |
283 | 278 |
fi |
284 | 279 |
|