Fix issue with leaking /tmp/image.* directories

When building the ramdisk we don't cleanup the temporary
directories after ourselves. This leaves /tmp/image.* directories
mounted and /tmp/image.* directories on the system.

Also the ramdisk-functions duplicate, from what I can see,
the cleanup function from common-functions. So when a job
is killed off it ends up leaving /tmp/image.* directories
on the system.

Change-Id: I2d73aabd0eb176027b4e7368580db08902e2b6ab
This commit is contained in:
Michael Kerrin 2015-01-27 18:45:55 +00:00
parent 04a542134f
commit 6337e6fe17
3 changed files with 5 additions and 21 deletions

View File

@ -251,13 +251,11 @@ if [ "$IS_RAMDISK" == "0" ]; then
for IMAGE_TYPE in ${IMAGE_TYPES[@]} ; do
compress_and_save_image $IMAGE_NAME.$IMAGE_TYPE
done
fi
# Always cleanup after ourselves
rm $TMP_IMAGE_PATH
cleanup_dirs
else
# This is a ramdisk build, we have already extracted the kernel and ramdisk
# by this point.
rm $TMP_IMAGE_PATH
fi
case "$IMAGE_ELEMENT" in
*ironic-agent*)

View File

@ -173,7 +173,7 @@ function cleanup_dirs () {
sudo rm -rf $TMP_BUILD_DIR/built
sudo rm -rf $TMP_BUILD_DIR/mnt
sudo umount -f $TMP_BUILD_DIR $TMP_IMAGE_DIR || true
rm -rf $TMP_BUILD_DIR $TMP_IMAGE_DIR
rm -rf --one-file-system $TMP_BUILD_DIR $TMP_IMAGE_DIR
}
# Run a directory of hooks outside the target (that is, no chrooting).

View File

@ -24,20 +24,6 @@ function fullpath() {
fi
}
function cleanup () {
if [ "$RAMDISK_ELEMENT" != "dracut-ramdisk" ]; then
unmount_dir "$TMP_BUILD_DIR/mnt"
fi
if [ -f "$TMP_IMAGE_PATH" ]; then
loopdev=`sudo losetup -j "$TMP_IMAGE_PATH" | cut -d: -f1`
if [ -n "$loopdev" ]; then
detach_loopback "$loopdev"
fi
fi
unmount_dir "$TMP_BUILD_DIR"
rm -rf --one-file-system "$TMP_BUILD_DIR"
}
function create_ramdisk_base () {
echo "Creating base system"