Problem:
When upgrading from Foreman 1.24/Katello 3.14 to Forman 2.0/Katello 3.15 and Foreman 2.1/Katello 3.16RC5, existing defined container products/repos fail to sync with the error “NoMethodError: undefined method `repository_href’ for nil:NilClass”. Problem manifested first with Katello upgrade instructions for 3.15, which had stuck tasks after “foreman-maintain advanced procedure run content-prepare” because it claimed that file content and docker content had already been migrated. Upgraded to Katello 3.16RC5, attempted the same content prepare/ content migrate steps, which also resulted in stuck tasks that stated the same thing. At least I could force cancel the tasks. Tried the sync operations with https://mcr.microsoft.com/, https://registry-1.docker.io/, and a private GitLab Container registry, all resulting in the same failure.
Deleting and recreating the Repo with the exact same information works properly. Looks like a migration issue from pulp2 to pulp3, as newly defined repos under pulp3 sync fine.
Expected outcome:
Sync behaviour should work the same as under Katello 3.14
Can you tell me what you see on your main smart proxy under Services -> Pulpcore? (https://<server_name>/smart_proxies/<your_pulp_master>#services). I’m looking for your content types being under Pulpcore. I’m thinking Yum will say it’s overridden to Pulp 2 but File and Docker will not.
Also, did you try the switchover? Or just the prepare procedure?
What was supposed to happen back in Katello 3.15 was that your Pulp 3 would be installed, but the configuration would be set to use Pulp 2 for Docker and File (Yum would be Pulp 2 as well since the Pulp 3 RPM plugin wasn’t installed). I expect there was a bug at some point (perhaps with the installer) and your Pulp 3 was fully switched over before you could do your migration. The migration will not run if it sees that File and Docker are set to use Pulp 3 instead of Pulp 2. If you’re curious, the code to check is here.
I suspect your repositories aren’t syncing because it’s trying to interact with Pulp 2 repos using Pulp 3. If I’m right about Pulp 3 already being in use (let’s confirm this first before trying the steps below), there are a couple ways we could try to fix this:
You can delete all of your old Pulp 2 File and Docker content and re-create it. This is the simplest route from a technical perspective, but if you have lots of content I can see it being a pain.
Or, we can try the migration again. If you’ve already started using Pulp 3, however, we will need to delete all of your newly created Pulp 3 repos (and content views) since the migration isn’t meant to be run after using Pulp 3. We’d then reset the Pulp 3 database with the following:
Then you can try the content-prepare and content-switchover.
One thing to keep in mind: While on Pulp 2, you can keep doing the content prepare procedure to bring content over to Pulp 3. Once you do the switchover, however, you will be on Pulp 3 from then on for Docker and File. The Yum migration to Pulp 3 is still being worked on.
Ok, so I see that Docker and File are using Pulp 3 (Pulpcore) right now, which is just as I expected. I can’t say for sure what went wrong with the upgrade to get your server in the situation, I’ll have to try an upgrade myself to see if it’s still a problem.
In your situation, I think the safest route will be to just delete the old Pulp 2 repositories and recreate them for Pulp 3.
Let us know for future upgrades if you do have more troubles with the Pulp 2 -> Pulp 3 content migrations. There will be one more that you’ll have to do for Yum before Katello 4.0 comes along. By then, we’ll have changed the code to detect which content types are already migrated so you shouldn’t see the same error.
I am having this problem when upgrading from katello-3.15.3 to katello-3.16.0
I get this error when trying to migrate the content:
[root@katello-testing ~]# foreman-maintain advanced procedure run content-switchover
Running ForemanMaintain::Scenario
================================================================================
Switch support for certain content from Pulp 2 to Pulp 3:
Performing final content migration before switching content
Content Migration completed successfully
Performing a check to verify everything that is needed has been migrated
[FAIL]
Failed executing foreman-rake katello:pulp3_post_migration_check, exit status 1:
rake aborted!
The Dynflow world was not initialized yet. If your plugin uses it, make sure to call Rails.application.dynflow.require! in some initializer
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/rails.rb:75:in `world'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-2.0.2/lib/foreman_tasks.rb:23:in `trigger'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-2.0.2/lib/foreman_tasks.rb:29:in `block in trigger_task'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-2.0.2/lib/foreman_tasks.rb:49:in `block in rails_safe_trigger_task'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.1/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.1/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.1/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-2.0.2/lib/foreman_tasks.rb:48:in `rails_safe_trigger_task'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-2.0.2/lib/foreman_tasks.rb:27:in `trigger_task'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-2.0.2/lib/foreman_tasks.rb:58:in `sync_task'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.16.0/lib/katello/tasks/pulp3_post_migration_check.rake:10:in `block (2 levels) in <top (required)>'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => katello:pulp3_post_migration_check
(See full trace by running task with --trace)
--------------------------------------------------------------------------------
Scenario [ForemanMaintain::Scenario] failed.
The following steps ended up in failing state:
[content-switchover]
Resolve the failed steps and rerun
the command. In case the failures are false positives,
use --whitelist="content-switchover"
If I try to remove the repositories to recreate them I get an error Repository guacamole_dockerhub cannot be deleted since it has already been included in a published Content View.
I tried to rollback my devel instance to katello-3.15.3 and executed foreman-maintain advanced procedure run content-prepare and I am getting error Pulp 3 migration cannot run. Types file, docker have already been migrated.
[root@katello-testing ~]# foreman-maintain advanced procedure run content-prepare
Running ForemanMaintain::Scenario
================================================================================
Prepare content for Pulp 3: [FAIL]
Failed executing foreman-rake katello:pulp3_migration, exit status 1:
rake aborted!
ForemanTasks::TaskError: Task 3120e425-e8aa-45d7-a694-97caa1a42059: Katello::Errors::Pulp3MigrationError: Pulp 3 migration cannot run. Types file, docker have already been migrated.
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.15.3.1/lib/katello/tasks/pulp3_migration.rake:15:in `block (2 levels) in <top (required)>'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => katello:pulp3_migration
(See full trace by running task with --trace)
--------------------------------------------------------------------------------
Scenario [ForemanMaintain::Scenario] failed.
The following steps ended up in failing state:
[content-prepare]
Resolve the failed steps and rerun
the command. In case the failures are false positives,
use --whitelist="content-prepare"
Have you previously run foreman-maintain advanced procedure run content-switchover and had it succeed? Perhaps when you started using Katello 3.15? The content-switchover task is a one-time deal for the content types it switches from Pulp 2 to Pulp 3. Your Docker and File content types are already using Pulp 3, which is why the migration is failing.
Some more info: At the moment, only Docker and File are being migrated to Pulp 3. Once the switchover is run successfully, all content for Docker and File will be permanently on Pulp 3. In a later release, you will do these steps again for Yum content.
If you definitely haven’t run the switchover, we can try some manual steps to fix your environment. Most of what I said above to @Mkbrown would apply to you too.
Sorry for the late reply but I have been offline for 2 weeks. I will be back to this post in coming days when I manage to clean my email backlog.
@poulterer I also tried to remove the repositories but those are already in a CV so I cannot remove them without removing the CV. I have no problem about deleting/adding the repos. Is there any way to force it?
I could delete the docker repos and add them again in my prod environment but in testing environment I keep getting this error when I try to delete the docker repo:
Repository 199 cannot be deleted since it has already been included in a published Content View.
But I only have one CV and when I go to the CV >> container images >> repositories I can only read There are currently no Docker Repositories associated with this Content View, you can add some by clicking on the "Add" tab above.
any suggestion about how I can force the removal of the docker repository to recreate it again?
It must be in an old version. I cannot look at this directly because we do not use Content Views for Docker repositories. We pull directly from the Foreman URL for a given repository.
Thanks for the pointer. The CV had more than 100 versions and one of the old ones had the containers included (I guess one of my colleagues did a test). After removing the old CV version I could remove the docker repos, upgrade katello and recreate the repos. Problem solved by now. Both my prod and testing environment are running latest katello 3.16.0. thanks