Skip to content

Commit

Permalink
Test if a manifest references an artifact when syncing
Browse files Browse the repository at this point in the history
The filter now ensures that the file of a manifest will be downloaded
when no referencing artifact exists.

closes #1400

(cherry picked from commit efe2772)
  • Loading branch information
lubosmj authored and patchback[bot] committed Oct 31, 2023
1 parent c150af5 commit 63f0516
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/1400.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed re-sync failures after reclaiming disk space.
4 changes: 2 additions & 2 deletions pulp_container/app/tasks/sync_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def _check_for_existing_manifest(self, download_tag):

if digest and (
manifest := await Manifest.objects.prefetch_related("contentartifact_set")
.filter(digest=digest)
.filter(digest=digest, _artifacts__isnull=False)
.afirst()
):
saved_artifact = await manifest._artifacts.aget()
Expand Down Expand Up @@ -470,7 +470,7 @@ async def create_listed_manifest(self, manifest_data):

if (
manifest := await Manifest.objects.prefetch_related("contentartifact_set")
.filter(digest=digest)
.filter(digest=digest, _artifacts__isnull=False)
.afirst()
):
saved_artifact = await manifest._artifacts.aget()
Expand Down
13 changes: 13 additions & 0 deletions pulp_container/tests/functional/api/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ def test_basic_sync(container_repo, container_remote, container_repository_api,
assert repository.latest_version_href == latest_version_href


def test_sync_reclaim_resync(
container_repo,
container_remote,
container_sync,
monitor_task,
repositories_reclaim_space_api_client,
):
"""Check if re-syncing the content after the reclamation ends with no error."""
container_sync(container_repo, container_remote)
monitor_task(repositories_reclaim_space_api_client.reclaim({"repo_hrefs": ["*"]}).task)
container_sync(container_repo, container_remote)


@pytest.mark.parallel
def test_sync_invalid_url(synced_container_repository_factory):
with pytest.raises(PulpTaskError) as ctx:
Expand Down

0 comments on commit 63f0516

Please sign in to comment.