Bug 2041701 - Fail to import contents when the connected and disconnected Satellite have different product labels for the same product
Summary: Fail to import contents when the connected and disconnected Satellite have di...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Inter Satellite Sync
Version: 6.10.0
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: 6.11.0
Assignee: satellite6-bugs
QA Contact: Radek Mynar
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-01-18 06:40 UTC by Hao Chang Yu
Modified: 2022-07-05 14:32 UTC (History)
3 users (show)

Fixed In Version: tfm-rubygem-katello-4.3.0.17-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2070999 (view as bug list)
Environment:
Last Closed: 2022-07-05 14:32:03 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 34501 0 High Closed Fail to import contents when the connected and disconnected servers have different product labels for the same product 2022-04-05 12:54:51 UTC
Red Hat Product Errata RHSA-2022:5498 0 None None None 2022-07-05 14:32:15 UTC

Description Hao Chang Yu 2022-01-18 06:40:34 UTC
Description of problem:
hammer content-import version --organization Default_Organization --path /var/lib/pulp/imports/Default_Organization/cv-ha/1.0/2022-01-13T19-50-44-11-00

Could not import the archive:
  The organization manifest does not contain the subscriptions required to enable the following repositories.
    * Product = 'Red Hat Enterprise Linux High Availability for x86_64', Repository = 'Red Hat Enterprise Linux High Availability for RHEL 7 Server RPM x86_64 7Server'


This is happening because the connected and disconnected Satellite have different product labels for the same product. For example, the connected Satellite has "Red_Hat_Enterprise_Linux_High_Availability_for_RHEL_Server_" (old product name) but the disconnected Satellite is expecting label "Red_Hat_Enterprise_Linux_High_Availability_for_x86_64" (new product name). Due to this mismatch, the import fails.

#<Katello::Product:0x0000000013fe9b20
 ...
 name: "Red Hat Enterprise Linux High Availability for x86_64",
 ...
 cp_id: "83",
 label: "Red_Hat_Enterprise_Linux_High_Availability__for_RHEL_Server_",  <==== connected satellite
 organization_id: 1,
 ...>

#<Katello::Product:0x0000000015596888
 ...
 name: "Red Hat Enterprise Linux High Availability for x86_64",
 ...
 cp_id: "83",
 label: "Red_Hat_Enterprise_Linux_High_Availability_for_x86_64",  <==== disconnected satellite
 ...>


This can be fixed by updating the product label of the connected Satellite.

----------------------------------------
foreman-rake console
prod = Katello::Product.find_by_name("Red Hat Enterprise Linux High Availability for x86_64")
prod.label = Katello::Util::Model.labelize(prod.name)
prod.save(validate: false)
exit
----------------------------------------

However, I am thinking it might be better to use the product name or the cp_id to validate the import instead of using product label. For example, "Red Hat Enterprise Linux Server", cp id is "69" and "Red Hat Enterprise Linux High Availability for x86_64" is "83". This is because product name is subject to change upstream but product label must be constant in Satellite.

Comment 1 Partha Aji 2022-02-07 19:58:17 UTC
The labels are generated by Katello from name field of the product. Once set they stay immutable (since it is used as key.)

So sounds like at some point "Red Hat Enterprise Linux High Availability for x86_64" was called "Red Hat Enterprise Linux High Availability for RHEL Server". A label was generated then  and when the manifest got re-imported on the connected server it updated the name but not the label. 

As Hao points out using the cp_id is probably a better idea at least for RH products.

Comment 2 Jonathon Turel 2022-02-23 11:22:20 UTC
Connecting redmine issue https://projects.theforeman.org/issues/34501 from this bug

Comment 3 Bryan Kearney 2022-03-10 20:05:07 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/34501 has been resolved.

Comment 6 Radek Mynar 2022-04-27 11:51:33 UTC
I created Export and Import organizations, imported manifest, synced RH Repository (Red Hat Satellite Capsule 6.10 for RHEL 7 Server RPMs x86_64) and prepared an export
Then launched following command in 'foreman-rake console' (organization_id: 4 is id of my import org):
 prod = Katello::Product.where(label: 'Red_Hat_Satellite_Capsule', organization_id: 4).first
 prod.update_attribute(:label, prod.label + "-updated")
After that i performed the import successfully.

I also checked presence of "cp_id" in metadata.json.
When label is changed, then import from older Satellite (without this fix and without cp_id in metadata.json) is not possible. Import of data without 'cp_id' is possible when label does not differ.

VERIFIED with Satellite 6.11 SNAP 17.0

Comment 9 errata-xmlrpc 2022-07-05 14:32:03 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 (Moderate: Satellite 6.11 Release), 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-2022:5498


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