Skip to content

Commit

Permalink
Remove the is_modular field from the Package model
Browse files Browse the repository at this point in the history
closes pulp#3524
  • Loading branch information
dralley committed May 7, 2024
1 parent a1fae15 commit 5b8e756
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 35 deletions.
1 change: 1 addition & 0 deletions CHANGES/3524.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the is_modular flag from Packages - it's not a reliable source of information.
1 change: 0 additions & 1 deletion docs/workflows/upload.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 2 additions & 9 deletions pulp_rpm/app/depsolving.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,18 +669,11 @@ def _load_from_version(self, repo_version, as_target=False):
"pk"
)

nonmodular_rpms = models.Package.objects.filter(
packages = models.Package.objects.filter(
pk__in=package_ids, is_modular=False
).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
Expand Down
17 changes: 17 additions & 0 deletions pulp_rpm/app/migrations/0062_remove_package_is_modular.py
Original file line number Diff line number Diff line change
@@ -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',
),
]
5 changes: 0 additions & 5 deletions pulp_rpm/app/models/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pulp_rpm/app/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
6 changes: 0 additions & 6 deletions pulp_rpm/app/serializers/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -312,7 +307,6 @@ class Meta:
"rpm_vendor",
"rpm_header_start",
"rpm_header_end",
"is_modular",
"size_archive",
"size_installed",
"size_package",
Expand Down
1 change: 0 additions & 1 deletion pulp_rpm/app/tasks/synchronizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions pulp_rpm/tests/functional/api/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion pulp_rpm/tests/functional/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion staging_docs/user/guides/02-upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5b8e756

Please sign in to comment.