Bug #38156
closedImporting into a repository that already exists on the importing instance broken
Description
To reproduce:¶
On the exporting Katello instance:
- Add a red hat manifest file
- Add a RHEL repo ("Red Hat Repositories" menu entry) and sync it
- Create a CV, add the RHEL repo, and publish and promote a version
- Now export the CV version using:
hammer content-export complete version --content-view="RHEL_9" --version=1.0 --organization="my_org"
- Copy the export to your importing Katello instance usinc scp or any other method:
scp -r /var/lib/pulp/exports/<your_export_folder>/ root@<importing_pulp_instance>:/var/lib/pulp/imports/
- Also add the red hat manifest file
- Add the same RHEL repo as on your exporting instance (you don't need to sync it)
- Now import the export you moved here from the exporting Katello instance:
chown -R pulp:pulp /var/lib/pulp/imports/<your_import_folder> hammer content-import version --organization="your_org" --path="/var/lib/pulp/imports/RHEL_9/1.0/2024-12-10T09-06-27-01-00/"
- The hammer command will ask you to do something like `foreman-rake katello:set_content_view_import_only ID=<some_id>` after which you can repeat the hammer command to actually start the import.
Expected result¶
Import task concludes successfully
Actual result¶
The error and first few lines of trace:
undefined method `content' for #<Katello::RootRepository id: 55, name: "Red Hat Enterprise Linux 8 for x86_64 - BaseOS RPM...", created_at: "2025-01-20 22:38:24.260907000 +0000", updated_at: "2025-01-20 22:38:24.260907000 +0000", major: 8, minor: "8", gpg_key_id: nil, content_id: "7416", arch: "noarch", label: "Red_Hat_Enterprise_Linux_8_for_x86_64_-_BaseOS_RPM...", url: "https://cdn.redhat.com/content/dist/rhel8/8/x86_64...", unprotected: false, content_type: "yum", product_id: 198, checksum_type: nil, pulp_scratchpad_checksum_type: nil, docker_upstream_name: nil, download_policy: "on_demand", verify_ssl_on_sync: true, upstream_username: nil, upstream_password: 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, include_tags: nil, description: nil, deb_errata_url: nil, deb_errata_url_etag: 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, retain_package_versions_count: nil, generic_remote_options: nil, upstream_authentication_token: nil, mirroring_policy: "mirror_complete", exclude_tags: nil, metadata_expire: nil, is_container_push: false, container_push_name: nil, container_push_name_format: nil, sync_dependencies: true> Did you mean? content_id (NoMethodError) /usr/share/gems/gems/activemodel-6.1.7.9/lib/active_model/attribute_methods.rb:469:in `method_missing' /usr/share/gems/gems/katello-4.13.1/app/services/katello/pulp3/content_view_version/importable_repositories.rb:32:in `block (2 levels) in generate!' /usr/share/gems/gems/activerecord-6.1.7.9/lib/active_record/relation/delegation.rb:88:in `each' /usr/share/gems/gems/activerecord-6.1.7.9/lib/active_record/relation/delegation.rb:88:in `each' /usr/share/gems/gems/activerecord-6.1.7.9/lib/active_record/relation/finder_methods.rb:68:in `find' /usr/share/gems/gems/activerecord-6.1.7.9/lib/active_record/relation/finder_methods.rb:68:in `find' /usr/share/gems/gems/activerecord-6.1.7.9/lib/active_record/associations/collection_proxy.rb:137:in `find' /usr/share/gems/gems/katello-4.13.1/app/services/katello/pulp3/content_view_version/importable_repositories.rb:30:in `block in generate!' /usr/share/gems/gems/katello-4.13.1/app/services/katello/pulp3/content_view_version/importable_repositories.rb:26:in `each' /usr/share/gems/gems/katello-4.13.1/app/services/katello/pulp3/content_view_version/importable_repositories.rb:26:in `generate!' /usr/share/gems/gems/katello-4.13.1/app/lib/actions/katello/content_view_version/auto_create_redhat_repositories.rb:12:in `plan' /usr/share/gems/gems/dynflow-1.8.4/lib/dynflow/action.rb:534:in `block (3 levels) in execute_plan' /usr/share/gems/gems/dynflow-1.8.4/lib/dynflow/middleware/stack.rb:28:in `pass' /usr/share/gems/gems/dynflow-1.8.4/lib/dynflow/middleware.rb:20:in `pass' /usr/share/gems/gems/dynflow-1.8.4/lib/dynflow/middleware.rb:37:in `plan' /usr/share/gems/gems/dynflow-1.8.4/lib/dynflow/middleware/stack.rb:24:in `call' /usr/share/gems/gems/dynflow-1.8.4/lib/dynflow/middleware/stack.rb:28:in `pass' /usr/share/gems/gems/dynflow-1.8.4/lib/dynflow/middleware.rb:20:in `pass' /usr/share/gems/gems/dynflow-1.8.4/lib/dynflow/middleware.rb:37:in `plan' /usr/share/gems/gems/dynflow-1.8.4/lib/dynflow/middleware/stack.rb:24:in `call' /usr/share/gems/gems/dynflow-1.8.4/lib/dynflow/middleware/stack.rb:28:in `pass' /usr/share/gems/gems/dynflow-1.8.4/lib/dynflow/middleware.rb:20:in `pass'
Analysis¶
This PR: https://github.com/Katello/katello/pull/11058 moved the "content" method from the root repository model to the Katello repository model. Apparently I missed updating the following invocation of it:
Because of the guard clause `if repo.content&.id && repo.redhat` only RHEL content is affected.
In addition, because of `root = product.root_repositories.find do |r|` I think the import is only affected if the importing instance already has the product and repository that is being imported. In our reproducer this is the case because we added the RHEL repo on both instances from the manifest. I believe it would also be the case if you were to import on a clean instance and then later were to import a newer state from the exporting instance to update your importing instance.
I theorize that we do not have a automatic test that covers "importing a repo that is already present in an earlier state from an earlier import" or we would have caught this earlier.
Updated by Quirin Pamp about 1 month ago
- Related to Feature #35959: Replace simple publisher with structured publisher for Debian Repositories added
Updated by The Foreman Bot about 1 month ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/Katello/katello/pull/11283 added
Updated by Jeremy Lenz about 1 month ago
- Category set to Inter Server Sync
- Target version changed from Katello 4.16.0 to Katello 4.15.1
- Difficulty set to medium
- Triaged changed from No to Yes
Updated by Quirin Pamp 29 days ago
- Status changed from Ready For Testing to Closed
Applied in changeset katello|eca16821b42141e29d328186234914f09735548a.