Skip to content

Commit

Permalink
[pulpcore] Don't collect args columns from tasks tables
Browse files Browse the repository at this point in the history
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: sosreport#3783
Resolves: sosreport#3784

Signed-off-by: Pavel Moravec <[email protected]>
  • Loading branch information
pmoravec authored and filanov committed Nov 24, 2024
1 parent 88012ef commit cb29f23
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions sos/report/plugins/pulpcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cb29f23

Please sign in to comment.