Importing a content view from a connected Red Hat Satellite 6 into a disconnected Red Hat Satellite 6.x server fails with "Could not import the archive.: undefined method `label' for nil:NilClass" error

Solution Verified - Updated

Environment

  • Disconnected Red Hat Satellite 6.x

Issue

Importing a content view from a connected Red Hat Satellite 6.x into a disconnected Red Hat Satellite 6.x server fails with the following error:

Could not import the archive.:
       undefined method `label' for nil:NilClass

Resolution

  • Start by applying the steps described in the Diagnostic Steps section of this solution.

  • If custom repositories that don't have content reference are detected on the disconnected Satellite server, then for each repository, run the following commands on the disconnected Satellite server, and verify that content_id: is nil for each:

# foreman-rake console
pp Katello::Repository.find(<Katello::Repository id from the third diagnostic step>).root
exit

For example:

# foreman-rake console
pp Katello::Repository.find(4517).root
exit

And observe content_id: nil, in the output:

 irb(main):003:0> Katello::Repository.find(4517).root
 => #<Katello::RootRepository id: 123, name: "3rd Party RPMs x86_64 7 Server", created_at: "2022-02-16 09:21:35", updated_at: "2022-02-16 09:21:35", major: nil, minor: nil, gpg_key_id: nil, content_id: nil, arch: "noarch", label: "Red_Hat_Enterprise_Linux_7_Server_3rd_Party_RPMs_x...", url: nil, unprotected: true, content_type: "yum", product_id: 94, checksum_type: "sha1", pulp_scratchpad_checksum_type: nil, docker_upstream_name: nil, mirror_on_sync: true, download_policy: "immediate", verify_ssl_on_sync: true, upstream_username: nil, upstream_password: nil, ostree_upstream_sync_policy: nil, ostree_upstream_sync_depth: nil, deb_releases: nil, deb_components: nil, deb_architectures: nil, ssl_ca_cert_id: nil, ssl_client_cert_id: nil, ssl_client_key_id: nil, ignorable_content: nil, docker_tags_whitelist: nil, description: nil, ansible_collection_requirements: nil, http_proxy_policy: "global_default_http_proxy", http_proxy_id: nil, download_concurrency: nil, os_versions: nil, ansible_collection_auth_url: nil, ansible_collection_auth_token: nil, upstream_authentication_token: nil>
irb(main):004:0>
  • Use hammer or Satellite's web UI to delete all of the custom repositories that don't have content reference and that were identified in the previous step from the disconnected Satellite server. To do this from the Satellite's web UI, navigate to Content -> Products, click on the specific product and remove these repositories.

  • Beware that the delete repository task will fail due to missing content id and the task will enter paused state. You will need to manually skip the failed dynflow step and resume.

  • Re-import the content view.

For more KB articles/solutions related to Red Hat Satellite 6.x Content View Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x Content View Issues

Root Cause

User cancels/deletes the paused import task and start a new one instead of resuming it after fixing the error. Due to this, the finalized step (which is responsible to update the content created in candlepin to the Katello custom repository) is skipped.

Diagnostic Steps

  • Run the following Postgres query on the disconnected Satellite server, and confirm that there are no paused tasks in the output from the query:
# sudo su - postgres -c "psql -d foreman -c 'select label,count(label),state,result from foreman_tasks_tasks where state <> '\''stopped'\'' group by label,state,result ORDER BY label;'"
  • Ensure that no import tasks are currently running on the disconnected Satellite server.

  • Verify that the output from the following Pulp query returns 200 when run on the disconnected Satellite server:

# curl --cert /etc/pki/katello/certs/pulp-client.crt --key /etc/pki/katello/private/pulp-client.key https://$(hostname -f)//pulp/api/v3/importers/core/pulp/
  • If the output from the previous curl command indicates that there are importers left behind, delete them by running the following commands on the disconnected Satellite server:
PULP_HREFS=$(curl --cert /etc/pki/katello/certs/pulp-client.crt --key /etc/pki/katello/private/pulp-client.key https://$(hostname -f)//pulp/api/v3/importers/core/pulp/|json_reformat |grep pulp_href|cut -d ':' -f 2|tr -d '",')

for pulp_href in $PULP_HREFS; do curl -X DELETE --cert /etc/pki/katello/certs/pulp-client.crt --key /etc/pki/katello/private/pulp-client.key https://$(hostname -f)$pulp_href;done
  • Check for custom repositories that don't have content reference by running the following command on the disconnected Satellite server and examining the output:
# foreman-rake console
pp Katello::RootRepository.all.select{|root| root.content.blank?}.map(&:repositories).flatten.select(&:library_instance?)
exit

The output from the above command may return one or more repositories. For example, the output below returned 2 repositories:

irb(main):001:0> Katello::RootRepository.all.select{|root| root.content.blank?}.map(&:repositories).flatten.select(&:library_instance?)
=> [#<Katello::Repository id: 4517, pulp_id: "e9bf4dbc-63cf-484b-9bef-72f646878117", library_instance_id: nil, content_view_version_id: 2, relative_path: "ORG1/Library/custom/ORG1_3rd_Party_Software_for_RH...", environment_id: 2, saved_checksum_type: nil, distribution_version: nil, distribution_arch: nil, distribution_bootable: nil, distribution_family: nil, distribution_variant: nil, container_repository_name: nil, root_id: 123, remote_href: nil, publication_href: "/pulp/api/v3/publications/rpm/rpm/c36c9144-38e1-4c...", version_href: "/pulp/api/v3/repositories/rpm/rpm/c373fcd0-0a46-4a...", last_contents_changed: "2022-02-16 09:22:06", last_applicability_regen: "1970-01-01 00:00:00", last_indexed: "2022-02-16 10:08:43">, #<Katello::Repository id: 4518, pulp_id: "d11f4733-eb03-4f0e-93fc-b5947dc9c26d", library_instance_id: nil, content_view_version_id: 2, relative_path: "ORG1/Library/custom/EPEL/EPEL_7_x86_64", environment_id: 2, saved_checksum_type: nil, distribution_version: nil, distribution_arch: nil, distribution_bootable: nil, distribution_family: nil, distribution_variant: nil, container_repository_name: nil, root_id: 124, remote_href: nil, publication_href: "/pulp/api/v3/publications/rpm/rpm/1b1ed3f4-d9eb-4d...", version_href: "/pulp/api/v3/repositories/rpm/rpm/fbe71531-41fd-45...", last_contents_changed: "2022-02-16 09:22:09", last_applicability_regen: "1970-01-01 00:00:00", last_indexed: "2022-02-16 10:08:45">]
irb(main):002:0> exit
SBR
Product(s)

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.