From 966f12dc4cd6f48f57a6d170d7fbccc5a28892a9 Mon Sep 17 00:00:00 2001 From: Gregory Haynes Date: Thu, 31 Dec 2015 19:41:11 +0000 Subject: [PATCH] Properly account for pipefail during cleanup Due to a bug in how we were running some of our phases we were not detecting some nonzero exit's. When this is fixed, dib fails early during cleanup (leaving some resources attatched) due to not propertly accounting for pipefail. Change-Id: Icc0b35acbe035cac12a9291e2d07b6c690c3a6ad --- lib/common-functions | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/common-functions b/lib/common-functions index 0f948260..b8ded27f 100644 --- a/lib/common-functions +++ b/lib/common-functions @@ -208,8 +208,9 @@ function detach_loopback() { # If setup on a rhel or derivative the map was created with kpartx not losetup # and subsequently needs to be removed. loopdev_name=$(echo $loopdev | sed 's/\/dev\///g') - mapper_name=$(sudo dmsetup ls | grep $loopdev_name | awk '{ print $1 }') - if [ "$mapper_name" ]; then + + if sudo dmsetup ls | grep $loopdev_name; then + mapper_name=$(sudo dmsetup ls | grep $loopdev_name | awk '{ print $1 }') sudo dmsetup --noudevsync remove $mapper_name fi @@ -282,7 +283,7 @@ function mount_proc_dev_sys () { function unmount_dir () { local pattern="$1" mnts="" - if [ -n "$pattern" ]; then + if [ -n "$pattern" ] && awk '{print $2}' < /proc/mounts | grep "^$pattern"; then mnts=`awk '{print $2}' < /proc/mounts | grep "^$pattern" | sort -r` fi if [ -n "$mnts" ]; then