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 1996103

Summary: document that pulp migration fails if there is an orphaned content
Product: Red Hat Satellite Reporter: Pavel Moravec <pmoravec>
Component: RepositoriesAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact: Cole Higgins <chiggins>
Severity: high Docs Contact:
Priority: medium    
Version: 6.10.0CC: ahumbe, jsherril, saydas, ttereshc
Target Milestone: Unspecified   
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: 2021-08-23 16:09:52 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 Pavel Moravec 2021-08-20 14:48:44 UTC
Description of problem:
pulp-2 to pulp-3 migration fails if there is some orphaned content. It can be resolved by running relevant rake script (and there is KCS 6273381 for it), but still I think we should add the step either to migration scripts or at least to migration documentation.

Arguments for doing so: it is quite probable more customers will hit the situation. Since in the attempt to shrink necessary data to migrate, they can disable unnecessary repos - what creates the orphans.

Also, I hit a situation where /etc/cron.weekly/pulp-maintenance automated cleanup did _not_ clean all orphans - while "foreman-rake katello:delete_orphaned_content" did. So there can be customers having the automated cleanup regularly running, but still having an orphaned content.


Version-Release number of selected component (if applicable):
Sat 6.9 -> 6.10 migration


How reproducible:
100%


Steps to Reproduce:
1. In Sat6.9, enable a repo with Immediate download policy, sync it and disable it.
2. run pulp-2 to pulp-3 migration script:
satellite-maintain content prepare


Actual results:
migration fails with:
Corrupted or missing content has been detected, you can examine the list of content in /tmp/unmigratable_content-20210820-9553-1e0yar9 and take action by either:
..

and the directory contains Rpms file with packages that cant be found in Satellite further.


Expected results:
Either update documentation to call

foreman-rake katello:delete_orphaned_content

prior the script/command. Or enahnce "content prepare" command by running the rake script.

(yet still that might not suffice: the rake script triggers orphans cleanup on _background_, which may terminate "too late", after the migration detects the problematic orphans - but is there an elegant solution for it (other "wait for cleanup completion"?).


Additional info:

Comment 1 Tanya Tereshchenko 2021-08-22 14:51:11 UTC
I believe pulp_2to3_migration migrates orphaned content and doesn't complain about it.
It think some checks on katello side trigger that message.

Changing to Repositories component.
Justin, it sounds very familiar, maybe it's a duplicate...

Comment 2 Sayan Das 2021-08-23 07:29:11 UTC
Tanya, I am aware of this one 

1971069 – [pulp3] run orphan katello unit deletion as part of 'content prepare'
https://bugzilla.redhat.com/show_bug.cgi?id=1971069

Bug #33131: [pulp3] run orphan katello unit deletion as part of 'content prepare' - Katello - Foreman
https://projects.theforeman.org/issues/33131


Is this the one you were looking for ?

Comment 3 Pavel Moravec 2021-08-23 09:46:27 UTC
(In reply to Sayan Das from comment #2)
> Tanya, I am aware of this one 
> 
> 1971069 – [pulp3] run orphan katello unit deletion as part of 'content
> prepare'
> https://bugzilla.redhat.com/show_bug.cgi?id=1971069
> 
> Bug #33131: [pulp3] run orphan katello unit deletion as part of 'content
> prepare' - Katello - Foreman
> https://projects.theforeman.org/issues/33131
> 
> 
> Is this the one you were looking for ?

That sounds to me to remove orhpaned content from katello, as it calls

Katello::Pulp3::MigrationSwitchover.new(SmartProxy.pulp_primary).remove_orphaned_content

that executes:

      def remove_orphaned_content
        models = []
        @migration.repository_types.each do |repo_type_label|
          repo_type = ::Katello::RepositoryTypeManager.repository_types[repo_type_label]
          indexable_types = repo_type.content_types_to_index
          models += indexable_types&.map(&:model_class)
          models.select! { |model| model.many_repository_associations }
        end
        models.each do |model|
          model.joins("left join katello_#{model.repository_association} on #{model.table_name}.id = katello_#{model.repository_association}.#{model.unit_id_field}").where("katello_#{model.repository_association}.#{model.unit_id_field} IS NULL").destroy_all
        end
      end

which operates over katello_* tables in DB.


In my case, pulp had orphaned content. Will the above clean it?


(I am adding this to my todo list to test this week..)

Comment 4 Justin Sherrill 2021-08-23 12:25:12 UTC
this won't be needed after  https://bugzilla.redhat.com/show_bug.cgi?id=1971069  is pulled into to the next z-stream, i propose we close this as a duplicate?

Comment 5 Justin Sherrill 2021-08-23 16:09:52 UTC
closing this as it shouldn't be needed after the next  6.9.z.  Let me know if you disagree

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