[PATCH] Retry automatically when package download fails (#732108)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Before displaying the error dialog, and waiting for user
interaction, retry the download for a few times.
This helps during some WAN install errors.

Conflicts:

	pyanaconda/constants.py
	pyanaconda/yuminstall.py
---
 pyanaconda/constants.py  |    4 ++++
 pyanaconda/yuminstall.py |   35 +++++++++++++++++++++++------------
 2 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py
index f8d4628..2e8c8ab 100644
--- a/pyanaconda/constants.py
+++ b/pyanaconda/constants.py
@@ -95,3 +95,7 @@ DRACUT_SHUTDOWN_EJECT = "/run/initramfs/usr/lib/dracut/hooks/shutdown/99anaconda
 
 # DMI information paths
 DMI_CHASSIS_VENDOR = "/sys/class/dmi/id/chassis_vendor"
+
+# number of retries before displaying an error dialog
+YUM_DOWNLOAD_RETRIES = 3
+YUM_DOWNLOAD_DELAY = 3
diff --git a/pyanaconda/yuminstall.py b/pyanaconda/yuminstall.py
index 0ca534b..764ee22 100644
--- a/pyanaconda/yuminstall.py
+++ b/pyanaconda/yuminstall.py
@@ -181,14 +181,16 @@ class AnacondaCallback:
             self.instLog.flush()
             self.openfile = None
 
+            trynumber = 0
             while self.openfile is None:
+                trynumber += 1
                 try:
                     fn = repo.getPackage(po)
 
                     f = open(fn, 'r')
                     self.openfile = f
                 except (yum.Errors.NoMoreMirrorsRepoError, IOError):
-                    self.ayum._handleFailure(po)
+                    self.ayum._handleFailure(po, trynumber)
                 except yum.Errors.RepoError:
                     continue
             self.inProgressPo = po
@@ -899,32 +901,41 @@ class AnacondaYum(yum.YumBase):
         self.repos.setCacheDir(self.conf.cachedir)
 
     def downloadHeader(self, po):
+        trynumber = 0
         while True:
             # retrying version of download header
+            trynumber += 1
             try:
                 yum.YumBase.downloadHeader(self, po)
                 break
             except (yum.Errors.NoMoreMirrorsRepoError, IOError):
-                self._handleFailure(po)
+                self._handleFailure(po, trynumber)
             except yum.Errors.RepoError:
                 continue
 
-    def _handleFailure(self, package):
+    def _handleFailure(self, package, trynumber=YUM_DOWNLOAD_RETRIES):
         if package.repo.anacondaBaseURLs[0].startswith("cdrom:"):
             buttons = [_("Re_boot"), _("_Eject")]
         else:
             buttons = [_("Re_boot"), _("_Retry")]
 
         pkgFile = to_unicode(os.path.basename(package.remote_path))
-        rc = self.anaconda.intf.messageWindow(_("Error"),
-                   _("The file %s cannot be opened.  This is due to a missing "
-                     "file, a corrupt package or corrupt media.  Please "
-                     "verify your installation source.\n\n"
-                     "If you exit, your system will be left in an inconsistent "
-                     "state that will likely require reinstallation.\n\n") %
-                                              (pkgFile,),
-                                    type="custom", custom_icon="error",
-                                    custom_buttons=buttons)
+
+        # only show the retry window after 3 tries
+        if trynumber < YUM_DOWNLOAD_RETRIES:
+            log.warning('package download failure, retrying automatically')
+            time.sleep(YUM_DOWNLOAD_DELAY * trynumber)
+            rc = 1
+        else:
+            rc = self.anaconda.intf.messageWindow(_("Error"),
+                       _("The file %s cannot be opened.  This is due to a missing "
+                         "file, a corrupt package or corrupt media.  Please "
+                         "verify your installation source.\n\n"
+                         "If you exit, your system will be left in an inconsistent "
+                         "state that will likely require reinstallation.\n\n") %
+                                                  (pkgFile,),
+                                        type="custom", custom_icon="error",
+                                        custom_buttons=buttons)
 
         if rc == 0:
             sys.exit(0)
-- 
1.7.9.5

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux