Blame SOURCES/sos-bz1781148-foreman-psql-dynflow-explicit-cast.patch

d1980b
From 5fbbc63c5e41eab4fe34e3bb2c76abf26023bd55 Mon Sep 17 00:00:00 2001
d1980b
From: Pavel Moravec <pmoravec@redhat.com>
d1980b
Date: Mon, 9 Dec 2019 13:22:34 +0100
d1980b
Subject: [PATCH] [foreman] cast dynflow_execution_plans.uuid as varchar
d1980b
d1980b
Due to a change in foreman DB scheme, we must explicitly cast
d1980b
dynflow_execution_plans.uuid as a varchar since foreman-tasks
d1980b
0.15.5 .
d1980b
d1980b
The explicit casting works well on older versions as well.
d1980b
d1980b
Resolves: #1882
d1980b
d1980b
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
d1980b
---
d1980b
 sos/plugins/foreman.py | 12 +++++++-----
d1980b
 1 file changed, 7 insertions(+), 5 deletions(-)
d1980b
d1980b
diff --git a/sos/plugins/foreman.py b/sos/plugins/foreman.py
d1980b
index c8ed2850..c1546eae 100644
d1980b
--- a/sos/plugins/foreman.py
d1980b
+++ b/sos/plugins/foreman.py
d1980b
@@ -176,22 +176,24 @@ class Foreman(Plugin):
d1980b
         dyncmd = (
d1980b
             'select dynflow_execution_plans.* from foreman_tasks_tasks join '
d1980b
             'dynflow_execution_plans on (foreman_tasks_tasks.external_id = '
d1980b
-            'dynflow_execution_plans.uuid) where foreman_tasks_tasks.'
d1980b
+            'dynflow_execution_plans.uuid::varchar) where foreman_tasks_tasks.'
d1980b
             'started_at > NOW() - interval %s' % quote(months)
d1980b
         )
d1980b
 
d1980b
         dactioncmd = (
d1980b
              'select dynflow_actions.* from foreman_tasks_tasks join '
d1980b
              'dynflow_actions on (foreman_tasks_tasks.external_id = '
d1980b
-             'dynflow_actions.execution_plan_uuid) where foreman_tasks_tasks.'
d1980b
-             'started_at > NOW() - interval %s' % quote(months)
d1980b
+             'dynflow_actions.execution_plan_uuid::varchar) where '
d1980b
+             'foreman_tasks_tasks.started_at > NOW() - interval %s'
d1980b
+             % quote(months)
d1980b
         )
d1980b
 
d1980b
         dstepscmd = (
d1980b
             'select dynflow_steps.* from foreman_tasks_tasks join '
d1980b
             'dynflow_steps on (foreman_tasks_tasks.external_id = '
d1980b
-            'dynflow_steps.execution_plan_uuid) where foreman_tasks_tasks.'
d1980b
-            'started_at > NOW() - interval %s' % quote(months)
d1980b
+            'dynflow_steps.execution_plan_uuid::varchar) where '
d1980b
+            'foreman_tasks_tasks.started_at > NOW() - interval %s'
d1980b
+            % quote(months)
d1980b
         )
d1980b
 
d1980b
         # Populate this dict with DB queries that should be saved directly as
d1980b
-- 
d1980b
2.21.0
d1980b
d1980b
From 40cfbd26a64d33cd3ed87edbf8d2b248d339ad9b Mon Sep 17 00:00:00 2001
d1980b
From: Pavel Moravec <pmoravec@redhat.com>
d1980b
Date: Thu, 5 Dec 2019 14:26:03 +0100
d1980b
Subject: [PATCH] [plugins] improve heuristic for applying --since to
d1980b
 logarchives
d1980b
d1980b
logarchive_pattern treats some configs (e.g. /etc/dbus-1) as log
d1980b
archives, causing --since option will skip collecting them.
d1980b
d1980b
This patch just improves the heuristic by claiming nothing under /etc
d1980b
is a logarchive, and adds a warning to sosreport help.
d1980b
d1980b
Improves: #1847
d1980b
d1980b
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
d1980b
---
d1980b
 man/en/sosreport.1      | 7 +++++--
d1980b
 sos/plugins/__init__.py | 5 ++++-
d1980b
 2 files changed, 9 insertions(+), 3 deletions(-)
d1980b
d1980b
diff --git a/man/en/sosreport.1 b/man/en/sosreport.1
d1980b
index a885d563..75819b6e 100644
d1980b
--- a/man/en/sosreport.1
d1980b
+++ b/man/en/sosreport.1
d1980b
@@ -158,8 +158,11 @@ and including logs in non-default locations. This option may significantly
d1980b
 increase the size of reports.
d1980b
 .TP
d1980b
 .B \--since YYYYMMDD[HHMMSS]
d1980b
-Limits the collection to logs newer than this date.
d1980b
-This also affects \--all-logs. Will pad with 0s if HHMMSS isn't specified.
d1980b
+Limits the collection of log archives to those newer than this date. A log
d1980b
+archive is any file not found in /etc, that has either a numeric or a
d1980b
+compression-type file extension for example ".zip". ".1", ".gz" etc.).
d1980b
+This also affects \--all-logs. The date string will be padded with zeros
d1980b
+if HHMMSS is not specified.
d1980b
 .TP
d1980b
 .B \--allow-system-changes
d1980b
 Run commands even if they can change the system (e.g. load kernel modules).
d1980b
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
d1980b
index b7a47b6a..44ae413d 100644
d1980b
--- a/sos/plugins/__init__.py
d1980b
+++ b/sos/plugins/__init__.py
d1980b
@@ -917,6 +917,7 @@ class Plugin(object):
d1980b
             since = self.get_option('since')
d1980b
 
d1980b
         logarchive_pattern = re.compile(r'.*((\.(zip|gz|bz2|xz))|[-.][\d]+)$')
d1980b
+        configfile_pattern = re.compile(r"^%s/*" % self.join_sysroot("etc"))
d1980b
 
d1980b
         if not self.test_predicate(pred=pred):
d1980b
             self._log_info("skipped copy spec '%s' due to predicate (%s)" %
d1980b
@@ -962,7 +963,9 @@ class Plugin(object):
d1980b
                 """ When --since is passed, or maxage is coming from the
d1980b
                 plugin, we need to filter out older files """
d1980b
 
d1980b
-                if logarchive_pattern.search(path) is None:
d1980b
+                # skip config files or not-logarchive files from the filter
d1980b
+                if ((logarchive_pattern.search(path) is None) or
d1980b
+                   (configfile_pattern.search(path) is not None)):
d1980b
                     return True
d1980b
                 filetime = datetime.fromtimestamp(getmtime(path))
d1980b
                 if ((since and filetime < since) or
d1980b
-- 
d1980b
2.21.0
d1980b