Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Fix a distribution tree LCE migration from a recreated pulp2 repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
goosemania committed Sep 2, 2020
1 parent ccc2e9f commit 5eaba43
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES/7080.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a distribution migration case when a repository in Pulp 2 has been recreated.
2 changes: 2 additions & 0 deletions pulp_2to3_migration/app/plugin/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ def get_remote_by_importer_id(importer_id):
# find already created pulp3 content
pulp3content = pulp2content.pulp3_content
extra_info = None
if is_multi_artifact:
extra_info = pulp_2to3_detail_content.get_treeinfo_serialized()

else:
# create pulp3 content and assign relations if present
Expand Down
22 changes: 19 additions & 3 deletions pulp_2to3_migration/app/plugin/rpm/pulp_2to3_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,13 @@ def pre_migrate_content_detail(cls, content_batch):
for distribution in pulp2_distribution_content_batch]
cls.objects.bulk_create(pulp2distribution_to_save, ignore_conflicts=True)

def create_pulp3_content(self):
def get_treeinfo_serialized(self):
"""
Create a Pulp 3 Distribution content for saving later in a bulk operation.
Returns:
dict: a serialized treeinfo data
"""
namespaces = [".treeinfo", "treeinfo"]
for namespace in namespaces:
Expand All @@ -749,8 +753,20 @@ def create_pulp3_content(self):
treeinfo_serialized['variants'] = variants
# Reset build_timestamp so Pulp will fetch all the addons during the next sync
treeinfo_serialized['distribution_tree']['build_timestamp'] = 0
return (DistributionTree(**treeinfo_serialized["distribution_tree"]),
treeinfo_serialized)
return treeinfo_serialized

def create_pulp3_content(self):
"""
Create a Pulp 3 Distribution content for saving later in a bulk operation.
Returns:
(DistributionTree, dict): an in-memory DistributionTree content and serialized
treeinfo data
"""
treeinfo_serialized = self.get_treeinfo_serialized()
return (DistributionTree(**treeinfo_serialized["distribution_tree"]),
treeinfo_serialized)


class Pulp2PackageLangpacks(Pulp2to3Content):
Expand Down

0 comments on commit 5eaba43

Please sign in to comment.