Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/+collection_sync_latest.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Optimize collection sync to only fetch the latest version when no requirements filter is provided.
26 changes: 24 additions & 2 deletions pulp_ansible/app/tasks/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,23 @@ async def _find_all_collections_from_unpaginated_data(self):

async def _find_all_collections(self):
if self._unpaginated_collection_version_metadata:
await self._find_all_collections_from_unpaginated_data()
loop = asyncio.get_event_loop()
tasks = []
for namespace, collections in self._unpaginated_collection_metadata.items():
for name, collection in collections.items():
highest = (collection.get("highest_version") or {}).get("version")
version_spec = f"=={highest}" if highest else "*"
entry = RequirementsFileEntry(
name=f"{namespace}.{name}",
version=version_spec,
source=None,
)
tasks.append(
loop.create_task(self._fetch_collection_metadata(entry))
)
self.parsing_metadata_progress_bar.total = len(tasks)
await self.parsing_metadata_progress_bar.asave(update_fields=["total"])
await asyncio.gather(*tasks)
return

collection_endpoint, api_version = await self._get_paginated_collection_api(self.remote.url)
Expand All @@ -1014,12 +1030,18 @@ async def _find_all_collections(self):
for collection in collections:
if api_version == 2:
namespace = collection["namespace"]["name"]
latest_version = (
collection.get("latest_version") or {}
).get("version")
else:
namespace = collection["namespace"]
latest_version = (
collection.get("highest_version") or {}
).get("version")
name = collection["name"]
requirements_file = RequirementsFileEntry(
name=".".join([namespace, name]),
version="*",
version=f"=={latest_version}" if latest_version else "*",
source=None,
)
tasks.append(loop.create_task(self._fetch_collection_metadata(requirements_file)))
Expand Down
Loading