Add retry to update_bootloaders.sh cleanup function

Race conditions could prevent /tmp/esp.* from being properly unmounted
if it was quickly mounted then unmounted.  If the umount fails,
sleep briefly and then retry.

BUG=chromium-os:23442,chromium-os:23443
TEST=Ran build_image --test, saw umount failure but after script finished
  saw that directory was unmounted on second attempt so no leakage

Change-Id: I5b2260f5c99fcfa66027ebcfd69b6e3d5afe4b91
Reviewed-on: https://gerrit.chromium.org/gerrit/12115
Tested-by: Jon Kliegman <kliegs@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Ready: Jon Kliegman <kliegs@chromium.org>
This commit is contained in:
Jonathan Kliegman 2011-11-25 11:03:16 -05:00 committed by Gerrit
parent f02a0dae85
commit ae6baa2ea7

View File

@ -180,7 +180,14 @@ fi
ESP_FS_DIR=$(mktemp -d /tmp/esp.XXXXXX)
cleanup() {
set +e
if ! sudo umount "${ESP_FS_DIR}"; then
# There is a race condition possible on some ubuntu setups
# with mounting and unmounting a device very quickly
# Doing a quick sleep/retry as a temporary workaround
warn "Initial unmount failed. Possibly crosbug.com/23443. Retrying"
sleep 5
sudo umount "${ESP_FS_DIR}"
fi
if [[ -n "${ESP_DEV}" && -z "${ESP_DEV//\/dev\/loop*}" ]]; then
sudo losetup -d "${ESP_DEV}"
fi