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
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
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"
The host should be deleted and arf_reports of that host also be deleted as well.
Host can be deleted once we delete generated arf report.
The re-registered host , did not have a OSCAP Capsule attached to it, and so the report it generated also , didn't have one
Created redmine issue http://projects.theforeman.org/issues/21091 from this bug
Upstream bug assigned to firstname.lastname@example.org
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/21091 has been resolved.
Satellite-6.3 Snap 27
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.
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.