[PATCH] Properly retry package downloads (#924860)
Vratislav Podzimek
vpodzime at redhat.com
Wed Feb 12 06:39:43 UTC 2014
On Tue, 2014-02-11 at 21:33 +0100, Martin Kolman wrote:
> There are basically two cases where package download can fail:
> - when YUM is populating the transaction
> (this actually just checks the file exists)
> - when the transaction is started and packages are downloaded and
> installed
>
> Previously Anaconda did not attempt to retry the first one at all
> and made an unlimited number of attempts in the second one.
>
> This has been changed and Anaconda now does 10 retries separated
> by a pause that progressively grows from 0.5 to 256 seconds for
> the final wait before giving up. With this mechanism it should
> be possible to successfully install even with a very shaky connection.
>
> Signed-off-by: Martin Kolman <mkolman at redhat.com>
> ---
> scripts/anaconda-yum | 105 +++++++++++++++++++++++++++++++++++++++++----------
> 1 file changed, 86 insertions(+), 19 deletions(-)
>
> diff --git a/scripts/anaconda-yum b/scripts/anaconda-yum
> index 12a562f..259b0b7 100755
> --- a/scripts/anaconda-yum
> +++ b/scripts/anaconda-yum
> @@ -22,6 +22,7 @@ import logging
> import os
> import sys
> import argparse
> +import time
> import rpm
> import rpmUtils
> import yum
> @@ -29,6 +30,19 @@ from urlgrabber.grabber import URLGrabError
>
> YUM_PLUGINS = ["fastestmirror", "langpacks"]
>
> +MAX_DOWNLOAD_RETRIES = 10
> +
> +
> +def get_retry_delay(retry_number):
> + """ The retry delay start short and gets longer as the
> + number of retries increases, for 10 retries, the delay increases
> + from 0.5 to 256 seconds for the final delay before giving up
> +
> + :param int retry_number: retry counter
> + :returns float: time to wait in seconds
> + """
> + return 0.25*(2**retry_number)
It's a bit out of the scope of this patch, but maybe this function could
be turned into a generator and placed e.g. to pyanaconda/iutil.py so
that it is reusable in other parts of the codebase as well (in future).
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list