From aae984ed2101c932ee168ccaf4aad43b69987eb8 Mon Sep 17 00:00:00 2001 From: Daniel Alley Date: Tue, 7 May 2024 00:57:27 -0400 Subject: [PATCH] Remove the is_modular field from the Package model closes #3524 --- CHANGES/3524.removal | 1 + docs/workflows/upload.rst | 1 - pulp_rpm/app/depsolving.py | 13 ++----------- .../0062_remove_package_is_modular.py | 17 +++++++++++++++++ pulp_rpm/app/models/package.py | 5 ----- pulp_rpm/app/models/repository.py | 6 +++--- pulp_rpm/app/serializers/package.py | 6 ------ pulp_rpm/app/tasks/synchronizing.py | 1 - pulp_rpm/tests/functional/api/test_sync.py | 8 -------- pulp_rpm/tests/functional/constants.py | 1 - staging_docs/user/guides/02-upload.md | 1 - 11 files changed, 23 insertions(+), 37 deletions(-) create mode 100644 CHANGES/3524.removal create mode 100644 pulp_rpm/app/migrations/0062_remove_package_is_modular.py diff --git a/CHANGES/3524.removal b/CHANGES/3524.removal new file mode 100644 index 000000000..f163f07b7 --- /dev/null +++ b/CHANGES/3524.removal @@ -0,0 +1 @@ +Remove the is_modular flag from Packages - it's not a reliable source of information. \ No newline at end of file diff --git a/docs/workflows/upload.rst b/docs/workflows/upload.rst index 37b6d8ea8..97e102d91 100644 --- a/docs/workflows/upload.rst +++ b/docs/workflows/upload.rst @@ -72,7 +72,6 @@ Package GET response (after task complete): "fox.txt" ] ], - "is_modular": false, "location_base": "", "location_href": "fox-1.1-2.noarch.rpm", "name": "fox", diff --git a/pulp_rpm/app/depsolving.py b/pulp_rpm/app/depsolving.py index bfab3f23e..a0d26d31e 100644 --- a/pulp_rpm/app/depsolving.py +++ b/pulp_rpm/app/depsolving.py @@ -669,18 +669,9 @@ def _load_from_version(self, repo_version, as_target=False): "pk" ) - nonmodular_rpms = models.Package.objects.filter( - pk__in=package_ids, is_modular=False - ).values(*RPM_FIELDS) + packages = models.Package.objects.filter(pk__in=package_ids).values(*RPM_FIELDS) - for rpm in nonmodular_rpms.iterator(chunk_size=5000): - self._add_unit_to_solver(rpm_to_solvable, rpm, repo, libsolv_repo_name) - - modular_rpms = models.Package.objects.filter(pk__in=package_ids, is_modular=True).values( - *RPM_FIELDS - ) - - for rpm in modular_rpms.iterator(chunk_size=5000): + for rpm in packages.iterator(chunk_size=5000): self._add_unit_to_solver(rpm_to_solvable, rpm, repo, libsolv_repo_name) # Load modules into the solver diff --git a/pulp_rpm/app/migrations/0062_remove_package_is_modular.py b/pulp_rpm/app/migrations/0062_remove_package_is_modular.py new file mode 100644 index 000000000..d8e3da571 --- /dev/null +++ b/pulp_rpm/app/migrations/0062_remove_package_is_modular.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.10 on 2024-05-07 04:58 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('rpm', '0061_fix_modulemd_defaults_digest'), + ] + + operations = [ + migrations.RemoveField( + model_name='package', + name='is_modular', + ), + ] diff --git a/pulp_rpm/app/models/package.py b/pulp_rpm/app/models/package.py index aeab1d27a..059881f94 100644 --- a/pulp_rpm/app/models/package.py +++ b/pulp_rpm/app/models/package.py @@ -135,8 +135,6 @@ class Package(Content): First byte of the header rpm_header_end (BigInteger): Last byte of the header - is_modular (Bool): - Flag to identify if the package is modular size_archive (BigInteger): Size, in bytes, of the archive portion of the original package file @@ -229,9 +227,6 @@ class Package(Content): time_build = models.BigIntegerField(null=True) time_file = models.BigIntegerField(null=True) - # not part of createrepo_c metadata - is_modular = models.BooleanField(default=False) - # createrepo_c treats 'nosrc' arch (opensuse specific use) as 'src' so it can seem that two # packages are the same when they are not. By adding 'location_href' here we can recognize this. # E.g. glibc-2.26.11.3.2.nosrc.rpm vs glibc-2.26.11.3.2.src.rpm diff --git a/pulp_rpm/app/models/repository.py b/pulp_rpm/app/models/repository.py index bb2d08e20..b23aabd9c 100644 --- a/pulp_rpm/app/models/repository.py +++ b/pulp_rpm/app/models/repository.py @@ -447,9 +447,9 @@ def _apply_retention_policy(self, new_version): Package.objects.with_age() .filter( pk__in=new_version.content.filter(pulp_type=Package.get_pulp_type()), - is_modular=False, # don't want to filter out modular RPMs - ) - .only("pk") + ).exclude( + pk__in=pulp_rpm.app.models.modulemd.Modulemd_packages.values_list("package", flat=True), + ).only("pk") ) old_packages = [] diff --git a/pulp_rpm/app/serializers/package.py b/pulp_rpm/app/serializers/package.py index 010985258..e59c7466f 100644 --- a/pulp_rpm/app/serializers/package.py +++ b/pulp_rpm/app/serializers/package.py @@ -197,11 +197,6 @@ class PackageSerializer(SingleArtifactContentUploadSerializer, ContentChecksumSe help_text=_("Last byte of the header"), read_only=True, ) - is_modular = serializers.BooleanField( - help_text=_("Flag to identify if the package is modular"), - required=False, - read_only=True, - ) size_archive = serializers.IntegerField( help_text=_("Size, in bytes, of the archive portion of the original package file"), @@ -312,7 +307,6 @@ class Meta: "rpm_vendor", "rpm_header_start", "rpm_header_end", - "is_modular", "size_archive", "size_installed", "size_package", diff --git a/pulp_rpm/app/tasks/synchronizing.py b/pulp_rpm/app/tasks/synchronizing.py index c54ea63f9..890908bcd 100644 --- a/pulp_rpm/app/tasks/synchronizing.py +++ b/pulp_rpm/app/tasks/synchronizing.py @@ -1327,7 +1327,6 @@ def verification_and_skip_callback(pkg): # find if a package relates to a modulemd if dc.content.nevra in self.nevra_to_module.keys(): - dc.content.is_modular = True for dc_modulemd in self.nevra_to_module[dc.content.nevra]: dc.extra_data["modulemd_relation"].append(dc_modulemd) dc_modulemd.extra_data["package_relation"].append(dc) diff --git a/pulp_rpm/tests/functional/api/test_sync.py b/pulp_rpm/tests/functional/api/test_sync.py index 9422a9f37..ef216708d 100644 --- a/pulp_rpm/tests/functional/api/test_sync.py +++ b/pulp_rpm/tests/functional/api/test_sync.py @@ -944,10 +944,6 @@ def test_core_metadata(init_and_sync, rpm_package_api): ) assert list(diff) == [], list(diff) - # assert no package is marked modular - for pkg in get_content(repository.to_dict())[RPM_PACKAGE_CONTENT_NAME]: - assert pkg["is_modular"] is False - @pytest.mark.parallel def test_treeinfo_metadata(init_and_sync, rpm_content_distribution_trees_api): @@ -1045,10 +1041,6 @@ def module_obsolete_key(m): diff = dictdiffer.diff(m1, m2, ignore={"pulp_created", "pulp_href"}) assert list(diff) == [], list(diff) - # assert all package from modular repo is marked as modular - for pkg in get_content(repository.to_dict())[RPM_PACKAGE_CONTENT_NAME]: - assert pkg["is_modular"] is True - @pytest.mark.parallel def test_additive_mode(init_and_sync): diff --git a/pulp_rpm/tests/functional/constants.py b/pulp_rpm/tests/functional/constants.py index 5b866efa9..2de2c625e 100644 --- a/pulp_rpm/tests/functional/constants.py +++ b/pulp_rpm/tests/functional/constants.py @@ -237,7 +237,6 @@ ["dir", "/var/lib/", "complex"], ["ghost", "/var/log/", "complex.log"], ], - "is_modular": False, "location_base": "", "location_href": "complex-package-2.3.4-5.el8.x86_64.rpm", "md5": None, diff --git a/staging_docs/user/guides/02-upload.md b/staging_docs/user/guides/02-upload.md index 5f6335b04..07696107d 100644 --- a/staging_docs/user/guides/02-upload.md +++ b/staging_docs/user/guides/02-upload.md @@ -89,7 +89,6 @@ Package upload requires a valid RPM package. "rpm_vendor": "", "rpm_header_start": 280, "rpm_header_end": 1697, - "is_modular": false, "size_archive": 296, "size_installed": 42, "size_package": 1846,