From e6c139275c1500717f1470ab9fdbcb30f03e297f Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Thu, 16 Oct 2014 15:52:25 -0400 Subject: [PATCH] ANSUPDATE-3 Correct cinder cleanup Correcting cinder cleanup to first remove the cinder volumes and then remove the loop devices and not the other way around. Additionally an intentional deactivation of the volume groups has been added. Change-Id: I86a0851d660b4435bba355a13f0ec6e41dd3f1e5 --- playbooks/cleanup_cinder_volumes.yml | 23 +++++++++++++++++------ playbooks/files/cleanup_cinder_devices.sh | 7 +++++++ playbooks/files/cleanup_loop_devices.sh | 6 ++++++ 3 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 playbooks/files/cleanup_cinder_devices.sh create mode 100644 playbooks/files/cleanup_loop_devices.sh diff --git a/playbooks/cleanup_cinder_volumes.yml b/playbooks/cleanup_cinder_volumes.yml index f7842aa..92bc735 100644 --- a/playbooks/cleanup_cinder_volumes.yml +++ b/playbooks/cleanup_cinder_volumes.yml @@ -13,13 +13,24 @@ # See the License for the specific language governing permissions and # limitations under the License. --- -- name: "Detach any loop devices in use" - sudo: yes - shell: for loopdevice in `losetup -a| cut -d ':' -f 1`; do losetup --detach $loopdevice; done - name: "Remove any cinder volume mounts that may be present" sudo: yes - shell: for CINDER_VOLUME in `dmsetup ls 2>/dev/null | cut -f 1 |grep 'cinder--volumes'`; do dmsetup remove $CINDER_VOLUME; done + script: files/cleanup_cinder_devices.sh + register: test_cinder_cleanup ignore_errors: yes - register: test_cinder_volume_remove +- name: "If cinder cleanup failed, collect volume group data" + command: vgdisplay -v + when: instance_status == "ACTIVE" and test_cinder_cleanup.rc != 0 - include: step_fail_unmount.yml - when: instance_status == "ACTIVE" and test_cinder_volume_remove.rc != 0 + when: instance_status == "ACTIVE" and test_cinder_cleanup.rc != 0 +- name: "Detach any loop devices in use" + sudo: yes + script: files/cleanup_loop_devices.sh + register: test_loop_device_cleanup +- name: "Collect list of loop devices" + sudo: yes + command: losetup -a + ignore_errors: yes + when: test_loop_device_cleanup.rc != 0 +- include: step_fail_unmount.yml + when: instance_status == "ACTIVE" and test_loop_device_cleanup.rc != 0 diff --git a/playbooks/files/cleanup_cinder_devices.sh b/playbooks/files/cleanup_cinder_devices.sh new file mode 100644 index 0000000..35842f5 --- /dev/null +++ b/playbooks/files/cleanup_cinder_devices.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -eux + +for CINDER_VOLUME in `dmsetup ls 2>/dev/null | cut -f 1 |grep 'cinder--volumes'|grep -v pool`; do + dmsetup remove $CINDER_VOLUME +done +vgchange -a n diff --git a/playbooks/files/cleanup_loop_devices.sh b/playbooks/files/cleanup_loop_devices.sh new file mode 100644 index 0000000..e8913fe --- /dev/null +++ b/playbooks/files/cleanup_loop_devices.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -eux + +for loopdevice in `losetup -a| cut -d ':' -f 1`; do + losetup --detach $loopdevice +done