Actions
Bug #24257
closedcommand "foreman-rake reports:expire" does not delete reports
Status:
Closed
Priority:
Normal
Assignee:
Category:
Organizations and Locations
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1600450
The reports:expire doesn't work for ArfReport
- foreman-rake reports:expire days=0 report_type="ForemanOpenscap::ArfReport"
It produced a log
D, [2018-06-18T15:39:52.098271 #6509] DEBUG -- : SQL (0.3ms) DELETE FROM "reports" WHERE "reports"."type" IN ('ForemanOpenscap::ArfReport') AND (1=0) AND (reports.created_at < '2018-06-18 10:09:52')
I, [2018-06-18T15:39:52.098582 #6509] INFO -- : 2018-06-18 10:09:52 UTC: Expired 0 Foreman openscap/arf reports
The above query has condition --> AND (1=0)
Workaround:
diff --git a/lib/tasks/reports.rake b/lib/tasks/reports.rake index fb4400d..e2b7cc2 100644 --- a/lib/tasks/reports.rake +++ b/lib/tasks/reports.rake @@ -30,8 +30,9 @@ namespace :reports do conditions = {} conditions[:timerange] = ENV['days'].to_i.days if ENV['days'] conditions[:status] = ENV['status'].to_i if ENV['status'] - - report_type.expire(conditions) + User.as_anonymous_admin do + report_type.expire(conditions) + end end end
Actions