Skip to content

Commit

Permalink
Reject repositories that contain delta metadata in mirror mode
Browse files Browse the repository at this point in the history
backports: #9407
https://pulp.plan.io/issues/9407

fixes #9408

(cherry picked from commit ccbec06)
  • Loading branch information
dralley committed Sep 22, 2021
1 parent f0e1a78 commit ac56e87
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES/9408.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
For certain repos which use Delta RPMs (which Pulp 3 does not and will not support) we now reject syncing these repos with mirroring enabled to avoid confusing clients with unusable Delta metadata.
(backported from #9407)
6 changes: 5 additions & 1 deletion pulp_rpm/app/tasks/synchronizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,11 @@ async def run_repomdrecord_download(name, location_href, downloader):
checksum_types[record.type] = record_checksum_type
record.checksum_type = record_checksum_type

if self.mirror and record.location_base or ".." in record.location_href:
if self.mirror and (
record.location_base
or ".." in record.location_href
or record.type == "prestodelta"
):
raise ValueError(MIRROR_INCOMPATIBLE_REPO_ERR_MSG)

if not self.mirror and record.type not in types_to_download:
Expand Down
16 changes: 15 additions & 1 deletion pulp_rpm/tests/functional/api/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

from pulp_rpm.tests.functional.constants import (
AMAZON_MIRROR,
DRPM_UNSIGNED_FIXTURE_URL,
CENTOS7_OPSTOOLS,
PULP_TYPE_ADVISORY,
PULP_TYPE_MODULEMD,
Expand Down Expand Up @@ -1258,7 +1259,7 @@ def test_mirror_with_xml_base_fails(self):

def test_mirror_with_external_location_href_fails(self):
"""
Test that syncing a repository that uses contains an external location_href fails.
Test that syncing a repository that contains an external location_href fails in mirror mode.
External location_href refers to a location_href that points outside of the repo,
e.g. ../../Packages/blah.rpm
Expand All @@ -1270,6 +1271,19 @@ def test_mirror_with_external_location_href_fails(self):
error,
)

def test_mirror_with_delta_metadata_fails(self):
"""
Test that syncing a repository that contains prestodelta metadata fails in mirror mode.
Otherwise we would be mirroring the metadata without mirroring the DRPM packages.
"""
error = self.do_test(DRPM_UNSIGNED_FIXTURE_URL, mirror=True)

self.assertIn(
"features which are incompatible with 'mirror' sync",
error,
)

def do_test(self, url, mirror=False):
"""Sync a repository given ``url`` on the remote."""
repo_api = RepositoriesRpmApi(self.client)
Expand Down

0 comments on commit ac56e87

Please sign in to comment.