From 9947cdebd9ea88456a22e588f51ac93d9bbfadc8 Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Fri, 11 Oct 2013 09:50:12 +0100 Subject: [PATCH] Allow for bad Fedora image mirrors I am getting a lot of http 404's from Fedora mirrors, in particular in the US. Alternatively we could get cache-url to use previously existing files if they exist and there is an error but this may not be the correct thing todo in all cases. So for now we do a retry if HTTP 404 is returned to the request for a Fedora image. Change-Id: I7634aeac3bdfe6930fafe6d276186c09fc8587b5 --- elements/fedora/root.d/10-fedora-cloud-image | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/elements/fedora/root.d/10-fedora-cloud-image b/elements/fedora/root.d/10-fedora-cloud-image index 34e25f1b7..2b3f6b2ff 100755 --- a/elements/fedora/root.d/10-fedora-cloud-image +++ b/elements/fedora/root.d/10-fedora-cloud-image @@ -19,7 +19,19 @@ if [ -n "$DIB_OFFLINE" -a -f "$CACHED_TAR" ] ; then echo "Not checking freshness of cached $CACHED_TAR." else echo "Fetching Base Image" + + # There seems to be some bad Fedora mirrors returning http 404's for the cloud image. + # If the image fails to download due to a 404 we retry once. + set +e $TMP_HOOKS_PATH/bin/cache-url $DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE $DIB_IMAGE_CACHE/$BASE_IMAGE_FILE + RV=$? + set -e + + if [ "$RV" == "44" ] ; then + $TMP_HOOKS_PATH/bin/cache-url $DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE $DIB_IMAGE_CACHE/$BASE_IMAGE_FILE + elif [ "$RV" != "0" ] ; then + exit 1 + fi if [ ! -f $CACHED_TAR -o \ $DIB_IMAGE_CACHE/$BASE_IMAGE_FILE -nt $CACHED_TAR ] ; then