Blame SOURCES/sos-bz1789049-since-option-improved.patch

1b1872
From 71cdbde72f81d586da37a9e108868d6aa1b4ef69 Mon Sep 17 00:00:00 2001
1b1872
From: Pavel Moravec <pmoravec@redhat.com>
1b1872
Date: Thu, 5 Dec 2019 14:26:03 +0100
1b1872
Subject: [PATCH] [plugins] improve heuristic for applying --since to
1b1872
 logarchives
1b1872
1b1872
logarchive_pattern treats some configs (e.g. /etc/dbus-1) as log
1b1872
archives, causing --since option will skip collecting them.
1b1872
1b1872
This patch just improves the heuristic by claiming nothing under /etc
1b1872
is a logarchive, and adds a warning to sosreport help.
1b1872
1b1872
Improves: #1847
1b1872
1b1872
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
1b1872
---
1b1872
 man/en/sosreport.1      | 5 ++++-
1b1872
 sos/plugins/__init__.py | 5 ++++-
1b1872
 2 files changed, 8 insertions(+), 2 deletions(-)
1b1872
1b1872
diff --git a/man/en/sosreport.1 b/man/en/sosreport.1
1b1872
index a885d5630..f63b8deab 100644
1b1872
--- a/man/en/sosreport.1
1b1872
+++ b/man/en/sosreport.1
1b1872
@@ -158,8 +158,11 @@ and including logs in non-default locations. This option may significantly
1b1872
 increase the size of reports.
1b1872
 .TP
1b1872
 .B \--since YYYYMMDD[HHMMSS]
1b1872
-Limits the collection to logs newer than this date.
1b1872
+Limits the collection of log archives(*) to those newer than this date.
1b1872
 This also affects \--all-logs. Will pad with 0s if HHMMSS isn't specified.
1b1872
+(*) Sos interprets as a log archive any file not found in /etc, that has
1b1872
+either a numeric or compression-type extension for example '.zip'. '.1', '.gz'
1b1872
+ etc.)
1b1872
 .TP
1b1872
 .B \--allow-system-changes
1b1872
 Run commands even if they can change the system (e.g. load kernel modules).
1b1872
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
1b1872
index b7a47b6a4..44ae413d0 100644
1b1872
--- a/sos/plugins/__init__.py
1b1872
+++ b/sos/plugins/__init__.py
1b1872
@@ -917,6 +917,7 @@ def add_copy_spec(self, copyspecs, sizelimit=None, maxage=None,
1b1872
             since = self.get_option('since')
1b1872
 
1b1872
         logarchive_pattern = re.compile(r'.*((\.(zip|gz|bz2|xz))|[-.][\d]+)$')
1b1872
+        configfile_pattern = re.compile(r"^%s/*" % self.join_sysroot("etc"))
1b1872
 
1b1872
         if not self.test_predicate(pred=pred):
1b1872
             self._log_info("skipped copy spec '%s' due to predicate (%s)" %
1b1872
@@ -962,7 +963,9 @@ def time_filter(path):
1b1872
                 """ When --since is passed, or maxage is coming from the
1b1872
                 plugin, we need to filter out older files """
1b1872
 
1b1872
-                if logarchive_pattern.search(path) is None:
1b1872
+                # skip config files or not-logarchive files from the filter
1b1872
+                if ((logarchive_pattern.search(path) is None) or
1b1872
+                   (configfile_pattern.search(path) is not None)):
1b1872
                     return True
1b1872
                 filetime = datetime.fromtimestamp(getmtime(path))
1b1872
                 if ((since and filetime < since) or