Project

Profile

Help

Issue #6887

closed

migration doesn't seem to handle already-migrated 're-created' pulp2 repos

Added by jsherril@redhat.com over 4 years ago. Updated over 4 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
High
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Katello
Sprint:
Sprint 74
Quarter:

Description

If you do the following:

  1. create a repo in pulp2, sync it
  2. migrate the repo and create a distribution
  3. delete the repo in pulp2 and recreate it using the same repo id, resync it
  4. re-run the same migration plan

This results in a repo in pulp2 that matches the previously migrated repo's repo-id, but does NOT match its pulp 2 object id. It seems to result in these errors:

Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/rq/worker.py", line 886, in perform_job
rv = job.perform()
File "/usr/lib/python3.6/site-packages/rq/job.py", line 664, in perform
self._result = self._execute()
File "/usr/lib/python3.6/site-packages/rq/job.py", line 670, in _execute
return self.func(*self.args, **self.kwargs)
File "/usr/local/lib/python3.6/site-packages/pulp_2to3_migration/app/migration.py", line 231, in complex_repo_migrati
migrated_repo.pulp3_repository_version
File "/usr/local/lib/python3.6/site-packages/pulp_2to3_migration/app/migration.py", line 330, in migrate_repo_distrib
pulp2dist, repo_version)
File "/usr/local/lib/python3.6/site-packages/pulp_2to3_migration/app/plugin/rpm/repository.py", line 79, in migrate_t
defaults=distribution_data)
File "/usr/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/django/db/models/query.py", line 559, in update_or_create
obj, created = self._create_object_from_params(kwargs, params, lock=True)
File "/usr/lib/python3.6/site-packages/django/db/models/query.py", line 583, in _create_object_from_params
raise e
File "/usr/lib/python3.6/site-packages/django/db/models/query.py", line 575, in _create_object_from_params
obj = self.create(**params)
File "/usr/lib/python3.6/site-packages/django/db/models/query.py", line 422, in create
obj.save(force_insert=True, using=self.db)
File "/usr/local/lib/python3.6/site-packages/pulpcore/app/models/base.py", line 110, in save
return super().save(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/django/db/models/base.py", line 741, in save
force_update=force_update, update_fields=update_fields)
File "/usr/lib/python3.6/site-packages/django/db/models/base.py", line 776, in save_base
parent_inserted = self._save_parents(cls, using, update_fields)
File "/usr/lib/python3.6/site-packages/django/db/models/base.py", line 807, in _save_parents
force_insert=parent_inserted,
File "/usr/lib/python3.6/site-packages/django/db/models/base.py", line 870, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/usr/lib/python3.6/site-packages/django/db/models/base.py", line 908, in _do_insert
using=using, raw=raw)
File "/usr/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/django/db/models/query.py", line 1186, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1375, in execute_sql
cursor.execute(sql, params)
File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/usr/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "core_basedistribution_base_path_key"
DETAIL:  Key (base_path)=(ACME_Corporation/library_view/rhel_6_label) already exists.

: Traceback (most recent call last):
: File "/usr/lib/python3.6/site-packages/rq/worker.py", line 886, in perform_job
: rv = job.perform()
: File "/usr/lib/python3.6/site-packages/rq/job.py", line 664, in perform
: self._result = self._execute()
: File "/usr/lib/python3.6/site-packages/rq/job.py", line 670, in _execute
: return self.func(*self.args, **self.kwargs)
: File "/usr/local/lib/python3.6/site-packages/pulp_2to3_migration/app/migration.py", line 189, in complex_repo_migration
: pulp2_repo_id=pulp2_importer_repo_id
: File "/usr/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
: return getattr(self.get_queryset(), name)(*args, **kwargs)
: File "/usr/lib/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.Pulp2Importer.MultipleObjectsReturned: get() returned more than one Pulp2Importer -- it returned 4!

And results in an incomplete migration. I hit this while working on integration tests in katello (which do the same thing over and over), but could be a real scenario if the user deletes a repo and recreates it in between migrations.

Example migration plan to follow

Also available in: Atom PDF