Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1492998

Summary: Can't delete host , if the host has a arf-report that has no capsule attached
Product: Red Hat Satellite Reporter: Nikhil Kathole <nkathole>
Component: SCAP PluginAssignee: Ondřej Pražák <oprazak>
Status: CLOSED ERRATA QA Contact: Nikhil Kathole <nkathole>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: bbuckingham, ehelms, mhulan, oprazak, pcreech, sjagtap
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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.
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 17:02:18 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
screenshot of UI deleting host none

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 Satellite Program 2017-11-03 14:24:51 UTC
Upstream bug assigned to oprazak

Comment 8 Satellite Program 2017-11-03 14:24:55 UTC
Upstream bug assigned to oprazak

Comment 9 Satellite Program 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