From cb29f2369376dfbbb59baf973913d3d431527310 Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Tue, 24 Sep 2024 16:45:51 +0200 Subject: [PATCH] [pulpcore] Don't collect args columns from tasks tables These columns are either empty, containing passwords or some encoded data. Get the *remaining* column names and query for them. If the query for column names fail, failover to current "SELECT *". Relevant: #3783 Resolves: #3784 Signed-off-by: Pavel Moravec --- sos/report/plugins/pulpcore.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sos/report/plugins/pulpcore.py b/sos/report/plugins/pulpcore.py index f3696cd595..753af5d5d6 100644 --- a/sos/report/plugins/pulpcore.py +++ b/sos/report/plugins/pulpcore.py @@ -105,8 +105,15 @@ def setup(self): task_days = self.get_option('task-days') for table in ['core_task', 'core_taskgroup', 'core_groupprogressreport', 'core_progressreport']: - _query = (f"select * from {table} where pulp_last_updated > NOW()" - f" - interval '{task_days} days' order by" + _query = ("COPY (SELECT STRING_AGG(column_name, ', ') FROM " + f"information_schema.columns WHERE table_name='{table}'" + "AND table_schema = 'public' AND column_name NOT IN" + " ('args', 'kwargs', 'enc_args', 'enc_kwargs'))" + " TO STDOUT;") + col_out = self.exec_cmd(self.build_query_cmd(_query), env=self.env) + columns = col_out['output'] if col_out['status'] == 0 else '*' + _query = (f"select {columns} from {table} where pulp_last_updated" + f"> NOW() - interval '{task_days} days' order by" " pulp_last_updated") _cmd = self.build_query_cmd(_query) self.add_cmd_output(_cmd, env=self.env, suggest_filename=table)