Project

General

Profile

Bug #24257

command "foreman-rake reports:expire" does not delete reports

Added by Marek Hulán over 1 year ago. Updated over 1 year ago.

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

  1. 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

Related issues

Related to Foreman - Feature #23040: Anonymize Audit logsClosed2018-03-28
Related to Foreman - Bug #23623: Break report expiration into batchesClosed2018-05-17

Associated revisions

Revision 109836d4 (diff)
Added by Marek Hulán over 1 year ago

Fixes #24257 - load all reports and audits in tasks

History

#1 Updated by Marek Hulán over 1 year ago

  • Description updated (diff)
  • Subject changed from command "foreman-rake reports:expire" does not delete reports to command "foreman-rake reports:expire" does not delete reports

#2 Updated by Marek Hulán over 1 year ago

  • Category set to Organizations and Locations
  • Project changed from OpenSCAP to Foreman

in fact the clean script is in core, it does not take into account that other report types can be taxable. And as part of that, I checked our audits task which has the same flaw.

#3 Updated by The Foreman Bot over 1 year ago

  • Assignee set to Marek Hulán
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5839 added

#4 Updated by Marek Hulán over 1 year ago

  • Target version set to 1.18.1

I think this could be a good candidate for 1.18.1, mainly because of audits. The anonymization task was introduced in 1.18.0 by #23040

#5 Updated by Marek Hulán over 1 year ago

#6 Updated by Daniel Lobato Garcia over 1 year ago

  • Fixed in Releases 1.19.0 added

#7 Updated by Marek Hulán over 1 year ago

  • % Done changed from 0 to 100
  • Status changed from Ready For Testing to Closed

#8 Updated by The Foreman Bot over 1 year ago

  • Pull request https://github.com/theforeman/foreman/pull/5845 added

#9 Updated by Tomer Brisker over 1 year ago

  • Fixed in Releases 1.18.1 added

#10 Updated by Lukas Zapletal about 1 year ago

  • Related to Bug #23623: Break report expiration into batches added

Also available in: Atom PDF