Project

General

Profile

Actions

Bug #22668

closed

Removing reports without policy fails when proxy is down

Added by Ondřej Pražák almost 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Fixed in Releases:
Found in Releases:

Description

During upgrades, proxy is down and migrations are executed. Removing report file from proxy was moved into before_destroy filter. When before_destroy filter returns 'false', the record is not deleted. There are multiple problems:

  • call to logger returns 'false'
  • in 'destroy_from_proxy', we check if report has host. We should check if it has also policy and policy_arf_report, and proxy_id since we cannot delete the reprot without them.
  • when policy_arf_report is nil, we try to get the digest anyway and 'Undefined method `digest` for nil' is caught and masked.

Actual results:
[ INFO 2018-02-21 16:16:12 main] Upgrade Step: migrate_foreman...
[DEBUG 2018-02-21 16:16:39 main] rake aborted!
[DEBUG 2018-02-21 16:16:39 main] StandardError: An error has occurred, this and all later migrations canceled:
[DEBUG 2018-02-21 16:16:39 main]
[DEBUG 2018-02-21 16:16:39 main] Failed to destroy the record/opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/persistence.rb:185:in `destroy!'
[DEBUG 2018-02-21 16:16:39 main] /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_openscap-0.7.11/db/migrate/20171011134112_remove_arf_reports_without_policy.rb:5:in `map'
[DEBUG 2018-02-21 16:16:39 main] /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_openscap-0.7.11/db/migrate/20171011134112_remove_arf_reports_without_policy.rb:5:in `block in up'
[DEBUG 2018-02-21 16:16:39 main] /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/relation/batches.rb:124:in `find_in_batches'
[DEBUG 2018-02-21 16:16:39 main] /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_openscap-0.7.11/db/migrate/20171011134112_remove_arf_reports_without_policy.rb:4:in `up'
[DEBUG 2018-02-21 16:16:39 main] /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/migration.rb:611:in `exec_migration'

Expected results:
Upgrade finishes without error.


Related issues 1 (0 open1 closed)

Related to OpenSCAP - Bug #12390: When deleting ArfReport, it should be deleted from Smart Proxy as wellClosed11/04/2015Actions
Actions

Also available in: Atom PDF