From 63f051606748087445089b2c0b803662645bb244 Mon Sep 17 00:00:00 2001 From: Lubos Mjachky Date: Sat, 14 Oct 2023 22:39:01 +0200 Subject: [PATCH] Test if a manifest references an artifact when syncing The filter now ensures that the file of a manifest will be downloaded when no referencing artifact exists. closes #1400 (cherry picked from commit efe2772f4f8c11d2c4de821f8d589d56d21c6f41) --- CHANGES/1400.bugfix | 1 + pulp_container/app/tasks/sync_stages.py | 4 ++-- pulp_container/tests/functional/api/test_sync.py | 13 +++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 CHANGES/1400.bugfix diff --git a/CHANGES/1400.bugfix b/CHANGES/1400.bugfix new file mode 100644 index 000000000..b2ee5278e --- /dev/null +++ b/CHANGES/1400.bugfix @@ -0,0 +1 @@ +Fixed re-sync failures after reclaiming disk space. diff --git a/pulp_container/app/tasks/sync_stages.py b/pulp_container/app/tasks/sync_stages.py index 85d3c8a0f..df5da2ea8 100644 --- a/pulp_container/app/tasks/sync_stages.py +++ b/pulp_container/app/tasks/sync_stages.py @@ -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() @@ -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() diff --git a/pulp_container/tests/functional/api/test_sync.py b/pulp_container/tests/functional/api/test_sync.py index 2eb974beb..cb0931074 100644 --- a/pulp_container/tests/functional/api/test_sync.py +++ b/pulp_container/tests/functional/api/test_sync.py @@ -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: