Bug 2041701

Summary: Fail to import contents when the connected and disconnected Satellite have different product labels for the same product
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: Inter Satellite SyncAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: Radek Mynar <rmynar>
Severity: medium Docs Contact:
Priority: high    
Version: 6.10.0CC: ahumbe, paji, pcreech
Target Milestone: 6.11.0Keywords: PrioBumpGSS, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-4.3.0.17-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2070999 (view as bug list) Environment:
Last Closed: 2022-07-05 14:32:03 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 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