|
|
819553 |
From 5634f7dd77eff821f37daa953fa86cc783d3b937 Mon Sep 17 00:00:00 2001
|
|
|
819553 |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
819553 |
Date: Fri, 21 Jan 2022 16:27:33 +0100
|
|
|
819553 |
Subject: [PATCH] [foreman] Use psql-msgpack-decode wrapper for dynflow >= 1.6
|
|
|
819553 |
|
|
|
819553 |
In dynflow >=1.6.3, dynflow* tables in postgres are encoded by
|
|
|
819553 |
msgpack which makes plain CSV dumps unreadable. In such a case,
|
|
|
819553 |
psql-msgpack-decode wrapper tool from dynflow-utils (of any
|
|
|
819553 |
version) must be used instead of the plain psql command.
|
|
|
819553 |
|
|
|
819553 |
Resolves: #2830
|
|
|
819553 |
|
|
|
819553 |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
819553 |
---
|
|
|
819553 |
sos/report/plugins/foreman.py | 16 ++++++++++++----
|
|
|
819553 |
1 file changed, 12 insertions(+), 4 deletions(-)
|
|
|
819553 |
|
|
|
819553 |
diff --git a/sos/report/plugins/foreman.py b/sos/report/plugins/foreman.py
|
|
|
819553 |
index 314a651d1..3fd80e6a8 100644
|
|
|
819553 |
--- a/sos/report/plugins/foreman.py
|
|
|
819553 |
+++ b/sos/report/plugins/foreman.py
|
|
|
819553 |
@@ -244,8 +244,16 @@ def setup(self):
|
|
|
819553 |
self.add_cmd_output(_cmd, suggest_filename=table, timeout=600,
|
|
|
819553 |
sizelimit=100, env=self.env)
|
|
|
819553 |
|
|
|
819553 |
+ # dynflow* tables on dynflow >=1.6.3 are encoded and hence in that
|
|
|
819553 |
+ # case, psql-msgpack-decode wrapper tool from dynflow-utils (any
|
|
|
819553 |
+ # version) must be used instead of plain psql command
|
|
|
819553 |
+ dynutils = self.is_installed('dynflow-utils')
|
|
|
819553 |
for dyn in foremancsv:
|
|
|
819553 |
- _cmd = self.build_query_cmd(foremancsv[dyn], csv=True)
|
|
|
819553 |
+ binary = "psql"
|
|
|
819553 |
+ if dyn != 'foreman_tasks_tasks' and dynutils:
|
|
|
819553 |
+ binary = "/usr/libexec/psql-msgpack-decode"
|
|
|
819553 |
+ _cmd = self.build_query_cmd(foremancsv[dyn], csv=True,
|
|
|
819553 |
+ binary=binary)
|
|
|
819553 |
self.add_cmd_output(_cmd, suggest_filename=dyn, timeout=600,
|
|
|
819553 |
sizelimit=100, env=self.env)
|
|
|
819553 |
|
|
|
819553 |
@@ -270,7 +278,7 @@ def setup(self):
|
|
|
819553 |
# collect http[|s]_proxy env.variables
|
|
|
819553 |
self.add_env_var(["http_proxy", "https_proxy"])
|
|
|
819553 |
|
|
|
819553 |
- def build_query_cmd(self, query, csv=False):
|
|
|
819553 |
+ def build_query_cmd(self, query, csv=False, binary="psql"):
|
|
|
819553 |
"""
|
|
|
819553 |
Builds the command needed to invoke the pgsql query as the postgres
|
|
|
819553 |
user.
|
|
|
819553 |
@@ -281,8 +289,8 @@ def build_query_cmd(self, query, csv=False):
|
|
|
819553 |
if csv:
|
|
|
819553 |
query = "COPY (%s) TO STDOUT " \
|
|
|
819553 |
"WITH (FORMAT 'csv', DELIMITER ',', HEADER)" % query
|
|
|
819553 |
- _dbcmd = "psql --no-password -h %s -p 5432 -U foreman -d foreman -c %s"
|
|
|
819553 |
- return _dbcmd % (self.dbhost, quote(query))
|
|
|
819553 |
+ _dbcmd = "%s --no-password -h %s -p 5432 -U foreman -d foreman -c %s"
|
|
|
819553 |
+ return _dbcmd % (binary, self.dbhost, quote(query))
|
|
|
819553 |
|
|
|
819553 |
def postproc(self):
|
|
|
819553 |
self.do_path_regex_sub(
|