Blame SOURCES/BZ-1337105-add-lazy-packages-caching-opt.patch

eb5f31
diff -up yum-3.4.3/docs/yum.conf.5.orig yum-3.4.3/docs/yum.conf.5
eb5f31
--- yum-3.4.3/docs/yum.conf.5.orig	2016-08-02 15:08:10.160947580 +0200
eb5f31
+++ yum-3.4.3/docs/yum.conf.5	2016-08-02 15:08:30.046853379 +0200
eb5f31
@@ -381,6 +381,13 @@ that Yum does. This option can take the
eb5f31
 `packages' means that only RPM package downloads should be cached (but not
eb5f31
 repository metadata downloads).
eb5f31
 
eb5f31
+`lazy:packages' means that act like `packages' unless package verification
eb5f31
+fails (e.g. the package download doesn't match the expected checksum), in which
eb5f31
+case try re-downloading the package as if `none' was set.  This value is a good
eb5f31
+compromise if you want to avoid issues caused by stale proxy cache after remote
eb5f31
+RPMs change contents without changing filenames (e.g. are pushed unsigned and
eb5f31
+later signed) but still want the benefits of package caching whenever possible.
eb5f31
+
eb5f31
 `none' means that no HTTP downloads should be cached.
eb5f31
 
eb5f31
 The default is `all'. This is recommended unless you are experiencing caching
eb5f31
diff -up yum-3.4.3/output.py.orig yum-3.4.3/output.py
eb5f31
--- yum-3.4.3/output.py.orig	2016-08-02 15:08:10.074947988 +0200
eb5f31
+++ yum-3.4.3/output.py	2016-08-02 15:08:30.053853346 +0200
eb5f31
@@ -472,6 +472,13 @@ class YumOutput:
eb5f31
         :raises: *errobj*.exception
eb5f31
         """
eb5f31
         self.logger.error('%s: %s', errobj.url, errobj.exception)
eb5f31
+        if hasattr(errobj, 'retry_no_cache') and errobj.retry_no_cache and \
eb5f31
+                errobj.exception.errno < 0:
eb5f31
+            self.logger.error(_('Trying again, now avoiding proxy cache.'))
eb5f31
+            # Raising an exception would cause urlgrabber to jump to the next
eb5f31
+            # mirror and what we want here is to retry with the same, so just
eb5f31
+            # return.
eb5f31
+            return
eb5f31
         self.logger.error(_('Trying other mirror.'))
eb5f31
         self.suggestKBaseArticle(errobj)
eb5f31
         raise errobj.exception
eb5f31
diff -up yum-3.4.3/yum/config.py.orig yum-3.4.3/yum/config.py
eb5f31
--- yum-3.4.3/yum/config.py.orig	2016-08-02 15:08:10.159947585 +0200
eb5f31
+++ yum-3.4.3/yum/config.py	2016-08-02 15:08:30.048853370 +0200
eb5f31
@@ -810,7 +810,8 @@ class YumConf(StartupConf):
eb5f31
     deltarpm_percentage = IntOption(75, range_min=0, range_max=100)
eb5f31
     deltarpm_metadata_percentage = IntOption(100, range_min=0)
eb5f31
 
eb5f31
-    http_caching = SelectionOption('all', ('none', 'packages', 'all'))
eb5f31
+    http_caching = SelectionOption('all', ('none', 'packages', 'all',
eb5f31
+                                           'lazy:packages'))
eb5f31
     metadata_expire = SecondsOption(60 * 60 * 6) # Time in seconds (6h).
eb5f31
     metadata_expire_filter = SelectionOption('read-only:present',
eb5f31
                                              ('never', 'read-only:future',
eb5f31
diff -up yum-3.4.3/yum/__init__.py.orig yum-3.4.3/yum/__init__.py
eb5f31
diff -up yum-3.4.3/yum.spec.orig yum-3.4.3/yum.spec
eb5f31
--- yum-3.4.3/yum.spec.orig	2016-08-02 15:08:10.150947628 +0200
eb5f31
+++ yum-3.4.3/yum.spec	2016-08-02 15:08:30.047853374 +0200
eb5f31
@@ -63,7 +63,7 @@ BuildRequires: python >= 2.4
eb5f31
 BuildRequires: rpm-python, rpm >= 0:4.4.2
eb5f31
 BuildRequires: python-iniparse
eb5f31
 BuildRequires: python-sqlite
eb5f31
-BuildRequires: python-urlgrabber >= 3.9.0-8
eb5f31
+BuildRequires: python-urlgrabber >= 3.10-8
eb5f31
 BuildRequires: yum-metadata-parser >= 1.1.0
eb5f31
 BuildRequires: pygpgme
eb5f31
 # End of CheckRequires
eb5f31
@@ -72,7 +72,7 @@ Requires: python >= 2.4
eb5f31
 Requires: rpm-python, rpm >= 0:4.4.2
eb5f31
 Requires: python-iniparse
eb5f31
 Requires: python-sqlite
eb5f31
-Requires: python-urlgrabber >= 3.9.0-8
eb5f31
+Requires: python-urlgrabber >= 3.10-8
eb5f31
 Requires: yum-metadata-parser >= 1.1.0
eb5f31
 Requires: pygpgme
eb5f31
 # rawhide is >= 0.5.3-7.fc18 ... as this is added.
eb5f31
diff -up yum-3.4.3/yum/yumRepo.py.orig yum-3.4.3/yum/yumRepo.py
eb5f31
--- yum-3.4.3/yum/yumRepo.py.orig	2016-08-02 15:08:10.104947846 +0200
eb5f31
+++ yum-3.4.3/yum/yumRepo.py	2016-08-02 15:08:30.052853351 +0200
eb5f31
@@ -336,6 +336,7 @@ class YumRepository(Repository, config.R
eb5f31
         self._repoXML = None
eb5f31
         self._oldRepoMDData = {}
eb5f31
         self.cache = 0
eb5f31
+        self._retry_no_cache = False
eb5f31
         self.mirrorlistparsed = 0
eb5f31
         self.yumvar = {} # empty dict of yumvariables for $string replacement
eb5f31
         self._proxy_dict = {}
eb5f31
@@ -993,6 +994,7 @@ Insufficient space in download directory
eb5f31
                             interrupt_callback=self.interrupt_callback,
eb5f31
                             checkfunc=checkfunc,
eb5f31
                             size=size,
eb5f31
+                            retry_no_cache=self._retry_no_cache,
eb5f31
                             **ugopts)
eb5f31
 
eb5f31
             remote = url + '/' + relative
eb5f31
@@ -1020,6 +1022,7 @@ Insufficient space in download directory
eb5f31
                                            checkfunc=checkfunc,
eb5f31
                                            http_headers=headers,
eb5f31
                                            size=size,
eb5f31
+                                           retry_no_cache=self._retry_no_cache,
eb5f31
                                            **kwargs
eb5f31
                                            )
eb5f31
             except URLGrabError, e:
eb5f31
@@ -1049,15 +1052,22 @@ Insufficient space in download directory
eb5f31
                     misc.unlink_f(local)
eb5f31
                     raise URLGrabError(-1, _('Package does not match intended download.'))
eb5f31
 
eb5f31
-        ret = self._getFile(url=basepath,
eb5f31
-                        relative=remote,
eb5f31
-                        local=local,
eb5f31
-                        checkfunc=checkfunc,
eb5f31
-                        text=text,
eb5f31
-                        cache=cache,
eb5f31
-                        size=package.size,
eb5f31
-                        **kwargs
eb5f31
-                        )
eb5f31
+        # We would normally pass this to _getFile() directly but that could
eb5f31
+        # break backward compatibility with plugins that override _getFile()
eb5f31
+        # (BZ 1360532).
eb5f31
+        self._retry_no_cache = self.http_caching == 'lazy:packages'
eb5f31
+        try:
eb5f31
+            ret = self._getFile(url=basepath,
eb5f31
+                            relative=remote,
eb5f31
+                            local=local,
eb5f31
+                            checkfunc=checkfunc,
eb5f31
+                            text=text,
eb5f31
+                            cache=cache,
eb5f31
+                            size=package.size,
eb5f31
+                            **kwargs
eb5f31
+                            )
eb5f31
+        finally:
eb5f31
+            self._retry_no_cache = False
eb5f31
 
eb5f31
         if not kwargs.get('async') and not package.verifyLocalPkg():
eb5f31
             # Don't return as "success" when bad.