Bug #34501
closedFail to import contents when the connected and disconnected servers have different product labels for the same product
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=2041701
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.