Bug #22668
closedRemoving reports without policy fails when proxy is down
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.
Updated by The Foreman Bot almost 7 years ago
- Status changed from New to Ready For Testing
- Assignee set to Ondřej Pražák
- Pull request https://github.com/theforeman/foreman_openscap/pull/327 added
Updated by Marek Hulán almost 7 years ago
- Related to Bug #12390: When deleting ArfReport, it should be deleted from Smart Proxy as well added
Updated by Marek Hulán almost 7 years ago
- Subject changed from Removing reports without policy fails when proxy is down to Removing reports without policy fails when proxy is down
- Translation missing: en.field_release set to 331
Updated by The Foreman Bot almost 7 years ago
- Pull request https://github.com/theforeman/foreman_openscap/pull/329 added
Updated by Marek Hulán almost 7 years ago
- Translation missing: en.field_release changed from 331 to 345
Updated by Marek Hulán almost 7 years ago
- Status changed from Ready For Testing to Closed