Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2067951

Summary: Failed to import content view version with "undefined method `label' for nil:NilClass" error
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: Inter Satellite SyncAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact: Radek Mynar <rmynar>
Severity: high Docs Contact:
Priority: high    
Version: 6.10.3CC: ahumbe, jpasqual, momran, paji, sadas, saydas, vsedmik
Target Milestone: 6.11.0Keywords: PrioBumpGSS, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 13:39:55 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-03-24 06:08:34 UTC
Description of problem:
Getting the following error when importing content view version to a disconnected Satellite.
--------------------------------------------------
hammer content-import version --organisation redhat --path /var/lib/pulp/imports/path/to/data/directory
Could not import the archive.:
  undefined method `label' for nil:NilClass


Actions::Katello::ContentViewVersion::Import
<snip>
Exception:
NoMethodError: undefined method `label' for nil:NilClass
Backtrace:
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.42/app/lib/actions/katello/repository/update.rb:25:in `plan'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/action.rb:515:in `block (3 levels) in execute_plan'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/middleware/stack.rb:27:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/middleware.rb:19:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/middleware.rb:36:in `plan'
<snip>
--------------------------------------------------


It appears to be an issue caused by the previous import failure. The import task failed in the paused state and it didn't get to the finalize step ( Actions::Candlepin::Environment::SetContent, Actions::Katello::Foreman::ContentUpdate) to update the created content (in Candlepin) to the Katello custom repository.


This is what my custom repo looks like when my import task is in paused state:
---------------------------------------------------
irb(main):117:0> pp Katello::Repository.find(137).root
#<Katello::RootRepository:0x0000000016052e98
 id: 11,
 name: "no-feed-repo",
 created_at: Tue, 22 Mar 2022 01:35:42 UTC +00:00,
 updated_at: Tue, 22 Mar 2022 01:35:42 UTC +00:00, <========
 major: nil,
 minor: nil,
 gpg_key_id: nil,
 content_id: nil, <===========
 arch: "noarch",
 label: "no-feed-repo",
 ...
---------------------------------------------------


After fixing error and resumed the import task and let the task finish.
----------------------------------------------------
irb(main):127:0> pp Katello::Repository.find(137).root
#<Katello::RootRepository:0x0000000015e6f450
 id: 11,
 name: "no-feed-repo",
 created_at: Tue, 22 Mar 2022 01:35:42 UTC +00:00,
 updated_at: Tue, 22 Mar 2022 01:45:03 UTC +00:00, <=======
 major: nil,
 minor: nil,
 gpg_key_id: nil,
 content_id: "1647912947738",  <==================== Value is set in the finalized step
 arch: "noarch",
 label: "no-feed-repo",
 url: nil,
 unprotected: true,
 content_type: "yum",
 product_id: 295,
 checksum_type: nil,
---------------------------------------------------

Which means, if user unlock or delete the paused task and try to import again with a new task then he will hit this bug.


Steps to Reproduce:
1. Export a content view with one or more custom repositories from a connected Satellite
2. Import the exported contents to the disconnected Satellite.

hammer content-import version --organisation my_org --path /var/lib/pulp/imports/path/to/data/directory

3. Somehow make the import task fail and enter paused state. E.g. hit a current import bugs. Make the index_content fail is one way.
4. Fix any issue that causing the import failure.
4. Delete or unlock the paused task and then run the hammer command again to import the contents.

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

Expected results:
Import successfully.

Katello should be able fix the data inconsistency caused by the previous import failure.
Alternatively, avoid setting the content_id of the custom repositories in the finalize steps to avoid the issue.


Additional information:
1) One workaround I can think of is to run the below command to find out which custom repositories are broken (have content_id is nil) and then delete them from the disconnected Satellite. The delete repository task will fail due to missing content id and enter paused state. User needs to manually skip and resume twice per task.

---------------------------------------------------
# foreman-rake console
pp Katello::RootRepository.all.select{|root| root.content.blank?}.map(&:repositories).flatten.select(&:library_instance?)
exit
---------------------------------------------------

Cons: The custom repository content which was created by the failed import task will still remain in Candlepin and will not be deleted. However, it shouldn't cause any issue staying there.


2) When hitting an issue importing contents, I think it is recommended to fix the issue and then resume the paused task to avoid any data inconsistency issue.

Comment 11 Partha Aji 2022-05-17 13:39:55 UTC

*** This bug has been marked as a duplicate of bug 2075031 ***

Comment 12 Red Hat Bugzilla 2023-09-15 01:53:14 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 365 days