Bug 1492998 - Can't delete host , if the host has a arf-report that has no capsule attached
Summary: Can't delete host , if the host has a arf-report that has no capsule attached
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: SCAP Plugin
Version: 6.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Ondřej Pražák
QA Contact: Nikhil Kathole
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-09-19 06:51 UTC by Nikhil Kathole
Modified: 2019-04-01 20:27 UTC (History)
6 users (show)

Fixed In Version: foreman_openscap 0.7.11
Doc Type: Bug Fix
Doc Text:
Cause: the system let arf reports being created even if host didn't have any openscap proxy assigned Consequence: such report did not get the link to proxy so later when we tried to work with the report, it failed. Also when user tried to delete the report host, it failed since the report could not be deleted. Fix: we do no longer import arf reports for hosts that do not have any openscap proxy set. Also we provide a rake task to clean all existing arf reports without proxy set. To use it, run the following foreman-rake foreman_openscap:clean_reports_without_proxy Result: After running the rake task, all reports that miss a link to a proxy will be deleted, which restores the ability to delete a host that had such report. No more reports should appear anymore.
Clone Of:
Environment:
Last Closed: 2018-02-21 17:02:18 UTC
Target Upstream Version:


Attachments (Terms of Use)
screenshot of UI deleting host (69.31 KB, image/png)
2017-09-19 06:51 UTC, Nikhil Kathole
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 21091 0 None None None 2017-09-25 11:49:18 UTC
Red Hat Bugzilla 1402513 0 medium CLOSED Can not delete host if there are SCAP reports for that host 2021-06-10 11:44:09 UTC

Internal Links: 1402513

Description Nikhil Kathole 2017-09-19 06:51:05 UTC
Created attachment 1327735 [details]
screenshot of UI deleting host

Description of problem: We had registered a content host to satellite and generated oscap arf_report.Later we unregistered the host and also deleted that host from UI.Now again registered the same host and generated oscap arf_report.The report generated under Hosts -> Reports and showed "No capsule found" in Oscap capsule column.Now, when we were trying to delete that content host, it shows "Error: PG::Error: ERROR: update or delete on table "hosts" violates foreign key constraint "reports_host_id_fk" on table "reports" DETAIL: Key (id)=(21) is still referenced from table "reports". : DELETE FROM "hosts" WHERE "hosts"."type" IN ('Host::Managed') AND "hosts"."id" = $1"

Version-Release number of selected component (if applicable):satellite 6.3 snap 16


How reproducible:always


Steps to Reproduce:
1. Register a content host
2. Generate arf report
3. Unregister the host
4. Delete host from UI
5. Register same host
6. Generate arf report
7. Try to delete a host

Actual results:
Could not delete host and It shows error as "Error: PG::Error: ERROR: update or delete on table "hosts" violates foreign key constraint "reports_host_id_fk" on table "reports" DETAIL: Key (id)=(21) is still referenced from table "reports". : DELETE FROM "hosts" WHERE "hosts"."type" IN ('Host::Managed') AND "hosts"."id" = $1"

Expected results:
The host should be deleted and arf_reports of that host also be deleted as well.

Additional info:
Host can be deleted once we delete generated arf report.

Comment 3 Sanket Jagtap 2017-09-19 07:05:18 UTC
The re-registered host , did not have a OSCAP Capsule attached to it, and so the report it generated also , didn't have one

Comment 5 Ondřej Pražák 2017-09-25 11:49:16 UTC
Created redmine issue http://projects.theforeman.org/issues/21091 from this bug

Comment 7 pm-sat@redhat.com 2017-11-03 14:24:51 UTC
Upstream bug assigned to oprazak@redhat.com

Comment 8 pm-sat@redhat.com 2017-11-03 14:24:55 UTC
Upstream bug assigned to oprazak@redhat.com

Comment 9 pm-sat@redhat.com 2017-11-23 11:23:17 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/21091 has been resolved.

Comment 10 Nikhil Kathole 2017-12-07 10:55:43 UTC
VERIFIED

Version Tested:
Satellite-6.3 Snap 27

steps:
1. Registered a content host
2. Generated arf report
3. Unregistered the host
4. Deleted host from UI
5. Registered same host
6. Generated arf report

arf report not uploaded in satellite as oscap capsule not attached and Production.log shows 

2017-12-07 05:36:18 4475de61 [app] [I] Current user: foreman_api_admin (administrator)
2017-12-07 05:36:18 4475de61 [app] [E] Failed to upload Arf Report, no OpenSCAP Capsule set for host <hostname>
2017-12-07 05:36:18 4475de61 [app] [I] Completed 422 Unprocessable Entity in 72ms (Views: 0.9ms | ActiveRecord: 4.6ms)

As no arf report uploaded to satellite from host having no oscap capsule attached, host can be deleted successfully.

Comment 11 Bryan Kearney 2018-02-21 17:02:18 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.

For information on the advisory, and where to find the updated files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:0336


Note You need to log in before you can comment on or make changes to this bug.