[ContentMigration] Katello::Errors::Pulp3Error: duplicate key value violates unique constraint "core_remote_name_key"

Problem:
Katello::Errors::Pulp3Error: duplicate key value violates unique constraint “core_remote_name_key”

# foreman-maintain content prepare
Running Prepare content for Pulp 3
================================================================================
Prepare content for Pulp 3: 
API controllers newer than Apipie cache! Run apipie:cache rake task to regenerate cache.
Starting task.
2021-04-28 09:16:41 +0200: Pre-migrating Pulp 2 ERRATUM content (general info) 82785/82785Migration failed, You will want to investigate: https://lxcfg1/foreman_tasks/tasks/3d0ec129-f2c0-490d-bcd2-d04e526b6400
rake aborted!
ForemanTasks::TaskError: Task 3d0ec129-f2c0-490d-bcd2-d04e526b6400: Katello::Errors::Pulp3Error: duplicate key value violates unique constraint "core_remote_name_key"
DETAIL:  Key (name)=(5cb70d04f995eb7add3f8e15-163a6785-dbe5-45a1-b089-35a374553b98) already exists.
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.18.2.1/lib/katello/tasks/pulp3_migration.rake:33: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)
                                                                      [FAIL]
Failed executing foreman-rake katello:pulp3_migration, exit status 1
--------------------------------------------------------------------------------
Scenario [Prepare content for Pulp 3] 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"

Expected outcome:

Foreman and Proxy versions:
Katello 3.18.2
foreman-2.3.3-1.el7.noarch
foreman-proxy-2.3.3-1.el7.noarch

Foreman and Proxy plugin versions:

Distribution and version:
CentOS Linux release 7.9.2009 (Core)

Other relevant data:
pulpcore-worker-8: /usr/lib/python3.6/site-packages/django/db/models/fields/init.py:1427: RuntimeWarning: DateTimeField Pulp2RepoContent.pulp2_created received a naive datetime (2021-04-27 14:08
:52) while time zone support is active.
2021-04-28T09:16:46.588681+02:00 lxcfg1 pulpcore-worker-8: RuntimeWarning)
2021-04-28T09:16:46.588903+02:00 lxcfg1 pulpcore-worker-8: pulp: rq.worker:ERROR: Traceback (most recent call last):
2021-04-28T09:16:46.589121+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/django/db/models/query.py”, line 554, in update_or_create
2021-04-28T09:16:46.589330+02:00 lxcfg1 pulpcore-worker-8: obj = self.select_for_update().get(**kwargs)
2021-04-28T09:16:46.589541+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/django/db/models/query.py”, line 408, in get
2021-04-28T09:16:46.589745+02:00 lxcfg1 pulpcore-worker-8: self.model._meta.object_name
2021-04-28T09:16:46.589956+02:00 lxcfg1 pulpcore-worker-8: pulp_deb.app.models.remote.AptRemote.DoesNotExist: AptRemote matching query does not exist.
2021-04-28T09:16:46.590156+02:00 lxcfg1 pulpcore-worker-8: During handling of the above exception, another exception occurred:
2021-04-28T09:16:46.590359+02:00 lxcfg1 pulpcore-worker-8: Traceback (most recent call last):
2021-04-28T09:16:46.590563+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/django/db/backends/utils.py”, line 84, in _execute
2021-04-28T09:16:46.590762+02:00 lxcfg1 pulpcore-worker-8: return self.cursor.execute(sql, params)
2021-04-28T09:16:46.590991+02:00 lxcfg1 pulpcore-worker-8: psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint “core_remote_name_key”
2021-04-28T09:16:46.591211+02:00 lxcfg1 pulpcore-worker-8: DETAIL: Key (name)=(5cb70d04f995eb7add3f8e15-163a6785-dbe5-45a1-b089-35a374553b98) already exists.
2021-04-28T09:16:46.591432+02:00 lxcfg1 pulpcore-worker-8: The above exception was the direct cause of the following exception:
2021-04-28T09:16:46.591652+02:00 lxcfg1 pulpcore-worker-8: Traceback (most recent call last):
2021-04-28T09:16:46.591863+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/rq/worker.py”, line 936, in perform_job
2021-04-28T09:16:46.592084+02:00 lxcfg1 pulpcore-worker-8: rv = job.perform()
2021-04-28T09:16:46.592288+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/rq/job.py”, line 684, in perform
2021-04-28T09:16:46.592518+02:00 lxcfg1 pulpcore-worker-8: self._result = self._execute()
2021-04-28T09:16:46.592728+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/rq/job.py”, line 690, in _execute
2021-04-28T09:16:46.593182+02:00 lxcfg1 pulpcore-worker-8: return self.func(*self.args, **self.kwargs)
2021-04-28T09:16:46.593433+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/pulp_2to3_migration/app/tasks/migrate.py”, line 80, in migrate_from_pulp2
2021-04-28T09:16:46.593666+02:00 lxcfg1 pulpcore-worker-8: migrate_importers(plan)
2021-04-28T09:16:46.593871+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/pulp_2to3_migration/app/migration.py”, line 134, in migrate_importers
2021-04-28T09:16:46.594080+02:00 lxcfg1 pulpcore-worker-8: remote, created = importer_migrator.migrate_to_pulp3(pulp2importer)
2021-04-28T09:16:46.594277+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/pulp_2to3_migration/app/plugin/deb/repository.py”, line 40, in migrate_to_pulp3
2021-04-28T09:16:46.594483+02:00 lxcfg1 pulpcore-worker-8: return AptRemote.objects.update_or_create(**base_config)
2021-04-28T09:16:46.594689+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/django/db/models/manager.py”, line 82, in manager_method
2021-04-28T09:16:46.594899+02:00 lxcfg1 pulpcore-worker-8: return getattr(self.get_queryset(), name)(*args, **kwargs)
2021-04-28T09:16:46.595095+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/django/db/models/query.py”, line 559, in update_or_create
2021-04-28T09:16:46.595290+02:00 lxcfg1 pulpcore-worker-8: obj, created = self._create_object_from_params(kwargs, params, lock=True)
2021-04-28T09:16:46.595517+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/django/db/models/query.py”, line 583, in _create_object_from_params
2021-04-28T09:16:46.595710+02:00 lxcfg1 pulpcore-worker-8: raise e
2021-04-28T09:16:46.595920+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/django/db/models/query.py”, line 575, in _create_object_from_params
2021-04-28T09:16:46.596119+02:00 lxcfg1 pulpcore-worker-8: obj = self.create(**params)
2021-04-28T09:16:46.596311+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/django/db/models/query.py”, line 422, in create
2021-04-28T09:16:46.596515+02:00 lxcfg1 pulpcore-worker-8: obj.save(force_insert=True, using=self.db)
2021-04-28T09:16:46.596713+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/pulpcore/app/models/base.py”, line 115, in save
2021-04-28T09:16:46.596930+02:00 lxcfg1 pulpcore-worker-8: return super().save(*args, **kwargs)
2021-04-28T09:16:46.597135+02:00 lxcfg1 pulpcore-worker-8: File “/usr/lib/python3.6/site-packages/django_lifecycle/mixins.py”, line 129, in save
2021-04-28T09:16:46.597341+02:00 lxcfg1 pulpcore-worker-8: save(*args, **kwargs)

Regards
Florian

Did you run foreman-installer after the latest update of the server?

Run

foreman-rake apipie:cache

to regenerate the cache and then try again.

1 Like