Bug 1584475 - [RFE] a script to automatically correct products
Summary: [RFE] a script to automatically correct products
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Other
Version: 6.3.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Katello QA List
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-31 02:26 UTC by matt jia
Modified: 2018-06-04 02:17 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-06-01 15:22:48 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description matt jia 2018-05-31 02:26:18 UTC
We often see this error:

2018-05-30 03:17:06 71ef6e3c [app] [E] RestClient::Gone: Katello::Resources::Candlepin::Consumer: 410 Gone {"displayMessage":"Unit 1ab7b861-bf5c-447d-8527-71b936314c76 has been deleted","requestUuid":"40a90ae6-e92c-4387-a7a7-05a43fc63f11","deletedId":"1ab7b861-bf5c-447d-8527-71b936314c76"} (GET /candlepin/consumers/1ab7b861-bf5c-447d-8527-71b936314c76)
 | Body: {"displayMessage":"Unit 1ab7b861-bf5c-447d-8527-71b936314c76 has been deleted","requestUuid":"40a90ae6-e92c-4387-a7a7-05a43fc63f11","deletedId":"1ab7b861-bf5c-447d-8527-71b936314c76"}
 | /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/abstract_response.rb:74:in `return!'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:495:in `process_result'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:421:in `block in transmit'

It is because katello and candlepin somehow got misaligned. To fix this issue, people need to delete the host in foreman-rake console. In some cases, it is quite risky to ask customers to perform this. Ideally, there should be a script like foreman-rake katello:correct_repositories to correct products in a safe manner:

foreman-rake katello:correct_products

Comment 1 Mike McCune 2018-06-01 15:22:48 UTC
This is handled in foreman-rake katello:clean_backend_objects

Comment 2 Mike McCune 2018-06-01 15:23:21 UTC
# foreman-rake katello:clean_backend_objects
The following changes will not actually be performed.  Rerun with COMMIT=true to apply the changes
0 orphaned consumer id(s) found in candlepin.
0 orphaned consumer id(s) found in pulp.

Comment 3 matt jia 2018-06-04 02:17:30 UTC
Hi Mike,

It seems like katello:clean_backend_objects only cleans up hosts and other stuff like orphaned consumers, but not orphaned products in foreman. By looking at

/home/mjia/katello/app/models/katello/glue/provider.rb L160-163

        product_to_remove_ids = (product_in_katello_ids - products_in_candlepin_ids).uniq
        product_to_remove_ids.each do |cp_id|
          product = Product.find_by_cp_id(cp_id, self.organization)
          Rails.logger.warn "Orphaned Product id #{product.id} found while refreshing/importing manifest."
        end
        end

Why a warning message is logged instead of deleting the orphaned product?


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