Issue #6062
closedMigration doesn't handle repos that are removed and then re-created
Description
If i generate a migration plan with some set of repositories, then one is removed in pulp2, and recreated with the same pulp_id. If i then re-run the exact same migration plan, pulp3 will error with this:
Traceback (most recent call last):
File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rq/worker.py", line 822, in perform_job
rv = job.perform()
File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rq/job.py", line 605, in perform
self._result = self._execute()
File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rq/job.py", line 611, in _execute
return self.func(*self.args, **self.kwargs)
File "/usr/local/lib/pulp/src/pulp/pulp_2to3_migration/app/tasks/migrate.py", line 116, in migrate_from_pulp2
loop.run_until_complete(migrate_distributors(plan))
File "/usr/lib64/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "/usr/local/lib/pulp/src/pulp/pulp_2to3_migration/app/migration.py", line 205, in migrate_distributors
migrated_repo = Pulp2Repository.objects.get(pulp2_repo_id=repo_id)
File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/db/models/query.py", line 412, in get
(self.model._meta.object_name, num)
pulp_2to3_migration.app.models.repository.Pulp2Repository.MultipleObjectsReturned: get() returned more than one Pulp2Repository -- it returned 2!
Traceback (most recent call last):
File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rq/worker.py", line 822, in perform_job
rv = job.perform()
File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rq/job.py", line 605, in perform
self._result = self._execute()
File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rq/job.py", line 611, in _execute
return self.func(*self.args, **self.kwargs)
od.27017[2028]: [conn229] end connection 127.0.0.1:41024 (39 connections now open)
File "/usr/local/lib/pulp/src/pulp/pulp_2to3_migration/app/tasks/migrate.py", line 116, in migrate_from_pulp2
loop.run_until_complete(migrate_distributors(plan))
File "/usr/lib64/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "/usr/local/lib/pulp/src/pulp/pulp_2to3_migration/app/migration.py", line 205, in migrate_distributors
migrated_repo = Pulp2Repository.objects.get(pulp2_repo_id=repo_id)
File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/db/models/query.py", line 412, in get
(self.model._meta.object_name, num)
pulp_2to3_migration.app.models.repository.Pulp2Repository.MultipleObjectsReturned: get() returned more than one Pulp2Repository -- it returned 2!
If you have trouble re-creating the issue, i can try to nail down exact steps, but it should be something like:
1. create a file repo in pulp2
2. Run a migration plan like:
{
"plugins":[
{
"type":"iso",
"repositories":[
{
"name":"5b08c8a6-d3bb-41af-9cd4-cadf8fec2a55",
"repository_versions":[
{
"pulp2_repository_id":"5b08c8a6-d3bb-41af-9cd4-cadf8fec2a55",
"pulp2_distributor_repository_ids":[
"5b08c8a6-d3bb-41af-9cd4-cadf8fec2a55"
]
}
],
"pulp2_importer_repository_id":"5b08c8a6-d3bb-41af-9cd4-cadf8fec2a55"
}
]
}
]
}
3. delete the repo in pulp2, recreate it with the exact same pulp_id for importers and distributors.
4. re-run the migration plan
Handle case when repos are removed and re-created.
closes #6062