Bug 1575140

Summary: Cannot delete host when missing from the candlepin database
Product: Red Hat Satellite Reporter: David Kaylor <dkaylor>
Component: Hosts - ContentAssignee: Justin Sherrill <jsherril>
Status: CLOSED ERRATA QA Contact: Lukáš Hellebrandt <lhellebr>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.3.1CC: aagrawal, ahumbe, ajoseph, andrew.schofield, cduryee, ehelms, gapatil, inecas, jbhatia, ktordeur, lhellebr, mmccune, molasaga, mverma, pcreech, peter.vreman, rlavande, stanislav.moravec, sthirugn, tbrisker, tdaianov, vwariyal
Target Milestone: 6.4.0Keywords: Reopened, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1609066 1624019 (view as bug list) Environment:
Last Closed: 2018-10-16 18:56:44 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:

Description David Kaylor 2018-05-04 20:52:54 UTC
Description of problem:
If a host cannot be found in the candlepin database, attempting to delete this host will fail with an error similar to the following:

Katello::Resources::Candlepin::Consumer: 404 Resource Not Found {"displayMessage":"Consumer with id e7d9a1f4-51f7-4b9a-b92b-43f72ce371de could not be found.","requestUuid":"22fcfb9a-6e57-46ca-8e39-184ec57035c2"} (DELETE /candlepin/consumers/e7d9a1f4-51f7-4b9a-b92b-43f72ce371de) 

Katello::Resources::Candlepin::Consumer: 404 Resource Not Found {"displayMessage":"Consumer with id d346d3f2-a287-4e55-8a93-eec225495245 could not be found.","requestUuid":"614508bb-5b43-4ac4-9768-ad82a884dfbb"} (DELETE /candlepin/consumers/d346d3f2-a287-4e55-8a93-eec225495245)

Version-Release number of selected component (if applicable):
Satellite 6.3.1

How reproducible:

The customer is not sure how the host got into its current state. I was able to reproduce it by manually deleting candlepin records from the database.


Steps to Reproduce:
1. Register a content host to Satellite
2. Connect to the candlepin database and run queries to delete the consumer. Example:

delete from cp_consumer_facts where cp_consumer_id = '4028fcae632b664d01632cc5dffd0000';
delete from cp_ent_certificate where entitlement_id in (select id from  cp_entitlement where consumer_id = '4028fcae632b664d01632cc5dffd0000');
delete from cp_entitlement where consumer_id = '4028fcae632b664d01632cc5dffd0000';
delete from cp_installed_products where consumer_id = '4028fcae632b664d01632cc5dffd0000';
delete from cp_consumer where id = '4028fcae632b664d01632cc5dffd0000';

3. Attempt to delete the host via the web UI or hammer

Actual results:
Host is not deleted and an error is received

Expected results:
Host is deleted

Additional info:
We also tried using the following but it did not help:

# foreman-rake katello:clean_backend_objects COMMIT=true
# foreman-rake katello:reimport

Comment 3 Satellite Program 2018-05-14 22:07:34 UTC
Upstream bug assigned to jsherril

Comment 4 Satellite Program 2018-05-14 22:07:37 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/23489 has been resolved.

Comment 13 Lukáš Hellebrandt 2018-07-26 11:43:14 UTC
Verified with Sat 6.4 snap 13.

Used reproducer from OP, the host got deleted, no traceback.

Comment 17 errata-xmlrpc 2018-08-22 20:07:12 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/RHBA-2018:2550

Comment 18 Mike McCune 2018-08-28 20:48:43 UTC
This bug was mistakenly added to https://access.redhat.com/errata/RHBA-2018:2550 6.3.3 but was not shipped in that update.

We will be releasing this in 6.3.4 and making a hotfix available here for anyone on 6.3.3 who needs this fix.

Comment 23 Bryan Kearney 2018-10-16 18:56:44 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:2927

Comment 24 Mike McCune 2018-10-18 16:49:30 UTC
*** Bug 1609066 has been marked as a duplicate of this bug. ***