Skip to content

Commit 7f516b4

Browse files
committed
Remove backward compatibility for artifactless manifest
This commit removes support for manifests storing their data inside an artifact instead of using the recently introduced Manifest.data text field. closes pulp#1621
1 parent 81e5f11 commit 7f516b4

File tree

4 files changed

+3
-114
lines changed

4 files changed

+3
-114
lines changed

pulp_container/app/redirects.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -91,47 +91,6 @@ def redirect_to_object_storage(self, artifact, return_media_type):
9191
)
9292
return redirect(content_url)
9393

94-
# TODO: BACKWARD COMPATIBILITY - remove after fully migrating to artifactless manifests
95-
def redirect_to_artifact(self, content_name, manifest, manifest_media_type):
96-
"""
97-
Search for the passed manifest's artifact and issue a redirect.
98-
"""
99-
try:
100-
artifact = manifest._artifacts.get()
101-
except ObjectDoesNotExist:
102-
raise Http404(f"An artifact for '{content_name}' was not found")
103-
104-
return self.redirect_to_object_storage(artifact, manifest_media_type)
105-
106-
def issue_tag_redirect(self, tag):
107-
"""
108-
Issue a redirect if an accepted media type requires it or return not found if manifest
109-
version is not supported.
110-
"""
111-
if tag.tagged_manifest.data:
112-
return super().issue_tag_redirect(tag)
113-
114-
manifest_media_type = tag.tagged_manifest.media_type
115-
if manifest_media_type == MEDIA_TYPE.MANIFEST_V1:
116-
return self.redirect_to_artifact(
117-
tag.name, tag.tagged_manifest, MEDIA_TYPE.MANIFEST_V1_SIGNED
118-
)
119-
elif manifest_media_type in get_accepted_media_types(self.request.headers):
120-
return self.redirect_to_artifact(tag.name, tag.tagged_manifest, manifest_media_type)
121-
else:
122-
raise ManifestNotFound(reference=tag.name)
123-
124-
def issue_manifest_redirect(self, manifest):
125-
"""
126-
Directly redirect to an associated manifest's artifact.
127-
"""
128-
if manifest.data:
129-
return super().issue_manifest_redirect(manifest)
130-
131-
return self.redirect_to_artifact(manifest.digest, manifest, manifest.media_type)
132-
133-
# END OF BACKWARD COMPATIBILITY
134-
13594

13695
class AzureStorageRedirects(S3StorageRedirects):
13796
"""

pulp_container/app/registry.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,6 @@ async def get_tag(self, request):
200200
"Content-Type": return_media_type,
201201
"Docker-Content-Digest": tag.tagged_manifest.digest,
202202
}
203-
# TODO: BACKWARD COMPATIBILITY - remove after fully migrating to artifactless manifest
204-
if not tag.tagged_manifest.data:
205-
return await self.dispatch_tag(request, tag, response_headers)
206-
# END OF BACKWARD COMPATIBILITY
207203
return web.Response(text=tag.tagged_manifest.data, headers=response_headers)
208204

209205
# return what was found in case media_type is accepted header (docker, oci)
@@ -213,41 +209,11 @@ async def get_tag(self, request):
213209
"Content-Type": return_media_type,
214210
"Docker-Content-Digest": tag.tagged_manifest.digest,
215211
}
216-
# TODO: BACKWARD COMPATIBILITY - remove after fully migrating to artifactless manifest
217-
if not tag.tagged_manifest.data:
218-
return await self.dispatch_tag(request, tag, response_headers)
219-
# END OF BACKWARD COMPATIBILITY
220212
return web.Response(text=tag.tagged_manifest.data, headers=response_headers)
221213

222214
# return 404 in case the client is requesting docker manifest v2 schema 1
223215
raise PathNotResolved(tag_name)
224216

225-
# TODO: BACKWARD COMPATIBILITY - remove after fully migrating to artifactless manifest
226-
async def dispatch_tag(self, request, tag, response_headers):
227-
"""
228-
Finds an artifact associated with a Tag and sends it to the client, otherwise tries
229-
to stream it.
230-
231-
Args:
232-
request(:class:`~aiohttp.web.Request`): The request to prepare a response for.
233-
tag: Tag
234-
response_headers (dict): dictionary that contains the 'Content-Type' header to send
235-
with the response
236-
237-
Returns:
238-
:class:`aiohttp.web.StreamResponse` or :class:`aiohttp.web.FileResponse`: The response
239-
streamed back to the client.
240-
241-
"""
242-
try:
243-
artifact = await tag.tagged_manifest._artifacts.aget()
244-
except ObjectDoesNotExist:
245-
ca = await sync_to_async(lambda x: x[0])(tag.tagged_manifest.contentartifact_set.all())
246-
return await self._stream_content_artifact(request, web.StreamResponse(), ca)
247-
else:
248-
return await Registry._dispatch(artifact, response_headers)
249-
# END OF BACKWARD COMPATIBILITY
250-
251217
@RegistryContentCache(
252218
base_key=lambda req, cac: Registry.find_base_path_cached(req, cac),
253219
auth=lambda req, cac, bk: Registry.auth_cached(req, cac, bk),
@@ -283,16 +249,6 @@ async def get_by_digest(self, request):
283249
"Content-Type": manifest.media_type,
284250
"Docker-Content-Digest": manifest.digest,
285251
}
286-
# TODO: BACKWARD COMPATIBILITY - remove after migrating to artifactless manifest
287-
if not manifest.data:
288-
if saved_artifact := await manifest._artifacts.afirst():
289-
return await Registry._dispatch(saved_artifact, headers)
290-
else:
291-
ca = await sync_to_async(lambda x: x[0])(manifest.contentartifact_set.all())
292-
return await self._stream_content_artifact(
293-
request, web.StreamResponse(), ca
294-
)
295-
# END OF BACKWARD COMPATIBILITY
296252
return web.Response(text=manifest.data, headers=headers)
297253
elif content_type == "blobs":
298254
ca = await ContentArtifact.objects.select_related("artifact", "content").aget(

pulp_container/app/tasks/sign.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,7 @@ async def create_signature(manifest, reference, signing_service):
100100
async with semaphore:
101101
# download and write file for object storage
102102
if not manifest.data:
103-
# TODO: BACKWARD COMPATIBILITY - remove after fully migrating to artifactless manifest
104-
artifact = await manifest._artifacts.aget()
105-
if settings.DEFAULT_FILE_STORAGE != "pulpcore.app.models.storage.FileSystem":
106-
async with tempfile.NamedTemporaryFile(dir=".", mode="wb", delete=False) as tf:
107-
await tf.write(await sync_to_async(artifact.file.read)())
108-
await tf.flush()
109-
artifact.file.close()
110-
manifest_path = tf.name
111-
else:
112-
manifest_path = artifact.file.path
113-
# END OF BACKWARD COMPATIBILITY
103+
pass # TODO: possible exception?
114104
else:
115105
async with tempfile.NamedTemporaryFile(dir=".", mode="wb", delete=False) as tf:
116106
await tf.write(manifest.data.encode("utf-8"))

pulp_container/app/tasks/sync_stages.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,8 @@ async def _check_for_existing_manifest(self, download_tag):
8484
):
8585
if raw_text_data := manifest.data:
8686
content_data = json.loads(raw_text_data)
87-
88-
# TODO: BACKWARD COMPATIBILITY - remove after fully migrating to artifactless manifest
89-
elif saved_artifact := await manifest._artifacts.afirst():
90-
content_data, raw_bytes_data = await sync_to_async(get_content_data)(saved_artifact)
91-
raw_text_data = raw_bytes_data.decode("utf-8")
92-
# if artifact is not available (due to reclaim space) we will download it again
9387
else:
94-
content_data, raw_text_data, response = await self._download_manifest_data(
95-
response.url
96-
)
97-
# END OF BACKWARD COMPATIBILITY
88+
pass # TODO: possible exception?
9889

9990
else:
10091
content_data, raw_text_data, response = await self._download_manifest_data(response.url)
@@ -477,15 +468,8 @@ async def create_listed_manifest(self, manifest_data):
477468
):
478469
if manifest.data:
479470
content_data = json.loads(manifest.data)
480-
# TODO: BACKWARD COMPATIBILITY - remove after fully migrating to artifactless manifest
481-
elif saved_artifact := await manifest._artifacts.afirst():
482-
content_data, _ = await sync_to_async(get_content_data)(saved_artifact)
483-
# if artifact is not available (due to reclaim space) we will download it again
484471
else:
485-
content_data, manifest = await self._download_and_instantiate_manifest(
486-
manifest_url, digest
487-
)
488-
# END OF BACKWARD COMPATIBILITY
472+
pass # TODO: possible exception?
489473
else:
490474
content_data, manifest = await self._download_and_instantiate_manifest(
491475
manifest_url, digest

0 commit comments

Comments
 (0)