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/+sync_repair_manifest_data.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add transparent repair code during Manifest sync to redownload the raw data in case it was lost during an upgrade.
45 changes: 35 additions & 10 deletions pulp_container/app/tasks/sync_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ async def _check_for_existing_manifest(self, head_manifest_task):
digest=digest, pulp_domain=get_domain()
).afirst():
raw_text_data = manifest.data
content_data = json.loads(raw_text_data)
if raw_text_data is None:
# This situation allegedly happens on some upgrade paths.
# A migration should mark the field not Null eventually. At that point this
# workaround can be removed.
content_data, raw_text_data, _ = await self._download_manifest_data(response.url)
manifest.data = raw_text_data
await manifest.asave()
else:
content_data = json.loads(raw_text_data)
else:
if not original_reference.startswith("sha256:") and digest:
# Fetch the tag with its digest
Expand Down Expand Up @@ -522,6 +530,8 @@ async def create_listed_manifest(self, manifest_data):

"""
digest = manifest_data["digest"]
# in oci-index spec, platform is an optional field
platform = manifest_data.get("platform", None)
relative_url = "/v2/{name}/manifests/{digest}".format(
name=self.remote.namespaced_upstream_name, digest=digest
)
Expand All @@ -530,15 +540,30 @@ async def create_listed_manifest(self, manifest_data):
if manifest := await Manifest.objects.filter(
digest=digest, pulp_domain=get_domain()
).afirst():
content_data = json.loads(manifest.data)

content_data, manifest = await self._download_and_instantiate_manifest(manifest_url, digest)

# in oci-index spec, platform is an optional field
platform = manifest_data.get("platform", None)
if platform:
manifest.os = platform["os"]
manifest.architecture = platform["architecture"]
raw_text_data = manifest.data
if raw_text_data is None:
# This situation allegedly happens on some upgrade paths.
# A migration should mark the field not Null eventually. At that point this
# workaround can be removed.
content_data, raw_text_data, response = await self._download_manifest_data(
manifest_url
)
media_type = determine_media_type(content_data, response)
validate_manifest(content_data, media_type, digest)
manifest.data = raw_text_data
if platform:
manifest.os = platform["os"]
manifest.architecture = platform["architecture"]
await manifest.asave()
else:
content_data = json.loads(raw_text_data)
else:
content_data, manifest = await self._download_and_instantiate_manifest(
manifest_url, digest
)
if platform:
manifest.os = platform["os"]
manifest.architecture = platform["architecture"]
man_dc = DeclarativeContent(content=manifest)
return {"manifest_dc": man_dc, "platform": platform, "content_data": content_data}

Expand Down
Loading