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: