Blame SOURCES/sos-bz1897903-postgresql_collect_rh-postgresql12.patch

c3caec
From 612ccc67233f14447f0a20a19916780f3def673f Mon Sep 17 00:00:00 2001
c3caec
From: Pavel Moravec <pmoravec@redhat.com>
c3caec
Date: Wed, 18 Nov 2020 10:21:17 +0100
c3caec
Subject: [PATCH] [postgresql] reorganize postgres from SCL
c3caec
c3caec
Backport of #2309 to legacy-3.9:
c3caec
- enable RedHatPostgreSQL also by rh-postgresql12 SCL
c3caec
- collect configs and logs regardless of running service
c3caec
- collect "du -sh" for SCL directories as well
c3caec
c3caec
Resolves: #2312
c3caec
c3caec
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
c3caec
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
c3caec
---
c3caec
 sos/plugins/postgresql.py | 54 +++++++++++++++++++++--------------------------
c3caec
 1 file changed, 24 insertions(+), 30 deletions(-)
c3caec
c3caec
diff --git a/sos/plugins/postgresql.py b/sos/plugins/postgresql.py
c3caec
index 2657992..ed36b3e 100644
c3caec
--- a/sos/plugins/postgresql.py
c3caec
+++ b/sos/plugins/postgresql.py
c3caec
@@ -82,47 +82,41 @@ class RedHatPostgreSQL(PostgreSQL, SCLPlugin):
c3caec
     packages = (
c3caec
         'postgresql',
c3caec
         'rh-postgresql95-postgresql-server',
c3caec
-        'rh-postgresql10-postgresql-server'
c3caec
+        'rh-postgresql10-postgresql-server',
c3caec
+        'rh-postgresql12-postgresql-server',
c3caec
     )
c3caec
 
c3caec
     def setup(self):
c3caec
         super(RedHatPostgreSQL, self).setup()
c3caec
 
c3caec
         pghome = self.get_option("pghome")
c3caec
+        dirs = [pghome]
c3caec
 
c3caec
-        scl = None
c3caec
         for pkg in self.packages[1:]:
c3caec
             # The scl name, package name, and service name all differ slightly
c3caec
             # but is at least consistent in doing so across versions, so we
c3caec
             # need to do some mangling here
c3caec
-            if self.is_service_running(pkg.replace('-server', '')):
c3caec
-                scl = pkg.split('-postgresql-')[0]
c3caec
-
c3caec
-        # Copy PostgreSQL log files.
c3caec
-        for filename in find("*.log", pghome):
c3caec
-            self.add_copy_spec(filename)
c3caec
-        for filename in find("*.log", self.convert_copyspec_scl(scl, pghome)):
c3caec
-            self.add_copy_spec(filename)
c3caec
-
c3caec
-        # Copy PostgreSQL config files.
c3caec
-        for filename in find("*.conf", pghome):
c3caec
-            self.add_copy_spec(filename)
c3caec
-        for filename in find("*.conf", self.convert_copyspec_scl(scl, pghome)):
c3caec
-            self.add_copy_spec(filename)
c3caec
-
c3caec
-        self.add_copy_spec(os.path.join(pghome, "data", "PG_VERSION"))
c3caec
-        self.add_copy_spec(os.path.join(pghome, "data", "postmaster.opts"))
c3caec
-
c3caec
-        self.add_copy_spec_scl(scl, os.path.join(pghome, "data", "PG_VERSION"))
c3caec
-        self.add_copy_spec_scl(scl, os.path.join(
c3caec
-                pghome,
c3caec
-                "data",
c3caec
-                "postmaster.opts"
c3caec
-            )
c3caec
-        )
c3caec
-
c3caec
-        if scl and scl in self.scls_matched:
c3caec
-            self.do_pg_dump(scl=scl, filename="pgdump-scl-%s.tar" % scl)
c3caec
+            scl = pkg.split('-postgresql-')[0]
c3caec
+            _dir = self.convert_copyspec_scl(scl, pghome)
c3caec
+            dirs.append(_dir)
c3caec
+            if os.path.isdir(_dir):
c3caec
+                self.add_cmd_output("du -sh %s" % _dir)
c3caec
+            if (self.is_service_running(pkg.replace('-server', '')) and
c3caec
+                    scl in self.scls_matched):
c3caec
+                self.do_pg_dump(scl=scl, filename="pgdump-scl-%s.tar" % scl)
c3caec
+
c3caec
+        for _dir in dirs:
c3caec
+            # Copy PostgreSQL log files.
c3caec
+            for filename in find("*.log", _dir):
c3caec
+                self.add_copy_spec(filename)
c3caec
+
c3caec
+            # Copy PostgreSQL config files.
c3caec
+            for filename in find("*.conf", _dir):
c3caec
+                self.add_copy_spec(filename)
c3caec
+
c3caec
+            # copy PG_VERSION and postmaster.opts
c3caec
+            for f in ["PG_VERSION", "postmaster.opts"]:
c3caec
+                self.add_copy_spec(os.path.join(_dir, "data", f))
c3caec
 
c3caec
 
c3caec
 class DebianPostgreSQL(PostgreSQL, DebianPlugin, UbuntuPlugin):
c3caec
-- 
c3caec
1.8.3.1
c3caec