diff --git a/CHANGES/8725.bugfix b/CHANGES/8725.bugfix new file mode 100644 index 00000000..2e4ba1dd --- /dev/null +++ b/CHANGES/8725.bugfix @@ -0,0 +1,4 @@ +Ensure a checksum type of a package is used for publications when a checksum type was not explicitly configured in Pulp 2. + +If you plan to perform sync from the migrated Pulp 3 to a Pulp 2 instance, this fix is important, otherwise you can ignore it. +If you've already started migration of the RPM plugin to Pulp 3, reset the migration for it and start again. diff --git a/pulp_2to3_migration/app/plugin/rpm/repository.py b/pulp_2to3_migration/app/plugin/rpm/repository.py index 58016762..b24efcfd 100644 --- a/pulp_2to3_migration/app/plugin/rpm/repository.py +++ b/pulp_2to3_migration/app/plugin/rpm/repository.py @@ -71,8 +71,21 @@ def migrate_to_pulp3(cls, pulp2distributor, repo_version): pulp2_checksum_type = pulp2_config.get('checksum_type') checksum_types = None if pulp2_checksum_type: - checksum_types = {'metadata': pulp2_checksum_type, - 'package': pulp2_checksum_type} + checksum_types = { + 'metadata': pulp2_checksum_type, + 'package': pulp2_checksum_type + } + else: + # Set the checksum type based on content in a repo, pulp 2 supports only one + # checksum type for packages in a repo. It is important to set checksum type for + # Pulp 3 to Pulp 2 sync use case. + package_qs = repo_version.content.filter(pulp_type='rpm.package') + if package_qs.count(): + pkg_checksum_type = package_qs.first().cast().checksum_type + checksum_types = { + 'metadata': pkg_checksum_type, + 'package': pkg_checksum_type + } sqlite = pulp2_config.get('generate_sqlite', False) try: publish(repo_version.pk, checksum_types=checksum_types, sqlite_metadata=sqlite)