Fix unmount/remove race in cleanup_build_dir

With a slow file system, umount can return 0 and the immediately
following remove can fail with a "Device or resource busy" error.
This happened in DevStack in disk-image-create where unmount_image
is followed by an immediate cleanup_build_dir.

Solution is to apply same logic from bug 1332521 to allow the
remove to retry on failure (up to 5s) in case the umount has not
completed.

Change-Id: I3337e2b4ad0111e77f79dc179439cdfea8ebdeda
Closes-Bug: #1527721
This commit is contained in:
James Arendt 2015-12-17 20:16:17 -08:00
parent c8c14edfe3
commit 12cb94a75d

View File

@ -173,7 +173,10 @@ function mount_qcow_image() {
}
function cleanup_build_dir () {
sudo rm -rf $TMP_BUILD_DIR/built
if ! timeout 5 sh -c " while ! sudo rm -rf $TMP_BUILD_DIR/built; do sleep 1; done"; then
echo "ERROR: unable to cleanly remove $TMP_BUILD_DIR/built"
exit 1
fi
sudo rm -rf $TMP_BUILD_DIR/mnt
if tmpfs_check 0; then
sudo umount -f $TMP_BUILD_DIR || true