Blame SOURCES/BZ-1369389-dont-recommend-makecache-if-running.patch

d2a170
commit 79591f49db4faec56a846ddf16a77004b8579ee7
d2a170
Author: Michal Domonkos <mdomonko@redhat.com>
d2a170
Date:   Thu Dec 15 16:23:10 2016 +0100
d2a170
d2a170
    Don't recommend makecache if just running. BZ 1369389
d2a170
    
d2a170
    Also includes any other commands that would result in all repos obeying
d2a170
    metadata_expire such as "yum install" (depending on the actual value of
d2a170
    metadata_expire_filter).
d2a170
d2a170
diff --git a/cli.py b/cli.py
d2a170
index 54a2e81..862992b 100755
d2a170
--- a/cli.py
d2a170
+++ b/cli.py
d2a170
@@ -450,11 +450,21 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
d2a170
 
d2a170
         if not ts_min:
d2a170
             cacheReq = 'write'
d2a170
-        elif warning and (time.time() - ts_max) > (60 * 60 * 24 * 14):
d2a170
-            self.logger.warning(_("Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast"))
d2a170
 
d2a170
+        all_obey = True
d2a170
         for repo in self.repos.sort():
d2a170
             repo._metadata_cache_req = cacheReq
d2a170
+            if repo._matchExpireFilter():
d2a170
+                all_obey = False
d2a170
+
d2a170
+        if warning and ts_min and (time.time() - ts_max) > (60 * 60 * 24 * 14):
d2a170
+            # The warning makes no sense if we're already running a command
d2a170
+            # that requires current repodata across all repos (such as "yum
d2a170
+            # makecache" or others, depending on metadata_expire_filter), so
d2a170
+            # don't give it if that's the case.
d2a170
+            if all_obey:
d2a170
+                return
d2a170
+            self.logger.warning(_("Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast"))
d2a170
 
d2a170
     def _shell_history_write(self):
d2a170
         if not hasattr(self, '_shell_history_cmds'):
d2a170
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
d2a170
index c6bed82..0c63de3 100644
d2a170
--- a/yum/yumRepo.py
d2a170
+++ b/yum/yumRepo.py
d2a170
@@ -1145,33 +1145,39 @@ Insufficient space in download directory %s
d2a170
             self._metadataCurrent = False
d2a170
         return self._metadataCurrent
d2a170
 
d2a170
-    def withinCacheAge(self, myfile, expiration_time, expire_req_filter=True):
d2a170
-        """check if any file is older than a certain amount of time. Used for
d2a170
-           the cachecookie and the mirrorlist
d2a170
-           return True if w/i the expiration time limit
d2a170
-           false if the time limit has expired
d2a170
-
d2a170
-           Additionally compare the file to age of the newest .repo or yum.conf
d2a170
-           file. If any of them are newer then invalidate the cache
d2a170
-           """
d2a170
-
d2a170
+    def _matchExpireFilter(self):
d2a170
+        """Return whether cache_req matches metadata_expire_filter."""
d2a170
         # Never/write means we just skip this...
d2a170
-        if (expire_req_filter and hasattr(self, '_metadata_cache_req') and
d2a170
-            self._metadata_cache_req.startswith("read-only:") and
d2a170
-            self.metadata_expire_filter.startswith("read-only:")):
d2a170
+        if (hasattr(self, '_metadata_cache_req') and
d2a170
+                self._metadata_cache_req.startswith("read-only:") and
d2a170
+                self.metadata_expire_filter.startswith("read-only:")):
d2a170
 
d2a170
             cache_filt = self.metadata_expire_filter[len("read-only:"):]
d2a170
             cache_req  = self._metadata_cache_req[len("read-only:"):]
d2a170
 
d2a170
             if cache_filt == 'future':
d2a170
                 assert cache_req in ('past', 'present', 'future')
d2a170
-                expiration_time = -1
d2a170
+                return True
d2a170
             if cache_filt == 'present':
d2a170
                 if cache_req in ('past', 'present'):
d2a170
-                    expiration_time = -1
d2a170
+                    return True
d2a170
             if cache_filt == 'past':
d2a170
                 if cache_req == 'past':
d2a170
-                    expiration_time = -1
d2a170
+                    return True
d2a170
+        return False
d2a170
+
d2a170
+    def withinCacheAge(self, myfile, expiration_time, expire_req_filter=True):
d2a170
+        """check if any file is older than a certain amount of time. Used for
d2a170
+           the cachecookie and the mirrorlist
d2a170
+           return True if w/i the expiration time limit
d2a170
+           false if the time limit has expired
d2a170
+
d2a170
+           Additionally compare the file to age of the newest .repo or yum.conf
d2a170
+           file. If any of them are newer then invalidate the cache
d2a170
+           """
d2a170
+
d2a170
+        if expire_req_filter and self._matchExpireFilter():
d2a170
+            expiration_time = -1
d2a170
 
d2a170
         # -1 is special and should never get refreshed
d2a170
         if expiration_time == -1 and os.path.exists(myfile):