|
25 | 25 | determine_media_type, |
26 | 26 | extract_data_from_signature, |
27 | 27 | filter_resources, |
| 28 | + get_content_data, |
28 | 29 | urlpath_sanitize, |
29 | 30 | validate_manifest, |
30 | 31 | ) |
@@ -83,11 +84,25 @@ async def _check_for_existing_manifest(self, download_tag): |
83 | 84 |
|
84 | 85 | digest = response.headers.get("docker-content-digest") |
85 | 86 |
|
86 | | - if manifest := await Manifest.objects.filter( |
87 | | - digest=digest, pulp_domain=get_domain() |
88 | | - ).afirst(): |
89 | | - raw_text_data = manifest.data |
90 | | - content_data = json.loads(raw_text_data) |
| 87 | + if ( |
| 88 | + manifest := await Manifest.objects.prefetch_related("contentartifact_set") |
| 89 | + .filter(digest=digest, pulp_domain=get_domain()) |
| 90 | + .afirst() |
| 91 | + ): |
| 92 | + if raw_text_data := manifest.data: |
| 93 | + content_data = json.loads(raw_text_data) |
| 94 | + |
| 95 | + # TODO: BACKWARD COMPATIBILITY - remove after fully migrating to artifactless manifest |
| 96 | + elif saved_artifact := await manifest._artifacts.afirst(): |
| 97 | + content_data, raw_bytes_data = await sync_to_async(get_content_data)(saved_artifact) |
| 98 | + raw_text_data = raw_bytes_data.decode("utf-8") |
| 99 | + # if artifact is not available (due to reclaim space) we will download it again |
| 100 | + else: |
| 101 | + content_data, raw_text_data, response = await self._download_manifest_data( |
| 102 | + response.url |
| 103 | + ) |
| 104 | + # END OF BACKWARD COMPATIBILITY |
| 105 | + |
91 | 106 | else: |
92 | 107 | content_data, raw_text_data, response = await self._download_manifest_data(response.url) |
93 | 108 |
|
@@ -364,7 +379,9 @@ async def get_paginated_tag_list(self, rel_link, repo_name): |
364 | 379 | while True: |
365 | 380 | link = urljoin(self.remote.url, rel_link) |
366 | 381 | list_downloader = self.remote.get_downloader(url=link) |
367 | | - await list_downloader.run(extra_data={"repo_name": repo_name}) |
| 382 | + # FIXME this can be rolledback after https://github.com/pulp/pulp_container/issues/1288 |
| 383 | + # tags/list endpoint does not like any unnecessary headers to be sent |
| 384 | + await list_downloader.run(extra_data={"repo_name": repo_name, "headers": {}}) |
368 | 385 | with open(list_downloader.path) as tags_raw: |
369 | 386 | tags_dict = json.loads(tags_raw.read()) |
370 | 387 | tag_list.extend(tags_dict["tags"]) |
@@ -507,12 +524,26 @@ async def create_listed_manifest(self, manifest_data): |
507 | 524 | ) |
508 | 525 | manifest_url = urljoin(self.remote.url, relative_url) |
509 | 526 |
|
510 | | - if manifest := await Manifest.objects.filter( |
511 | | - digest=digest, pulp_domain=get_domain() |
512 | | - ).afirst(): |
513 | | - content_data = json.loads(manifest.data) |
514 | | - |
515 | | - content_data, manifest = await self._download_and_instantiate_manifest(manifest_url, digest) |
| 527 | + if ( |
| 528 | + manifest := await Manifest.objects.prefetch_related("contentartifact_set") |
| 529 | + .filter(digest=digest, pulp_domain=get_domain()) |
| 530 | + .afirst() |
| 531 | + ): |
| 532 | + if manifest.data: |
| 533 | + content_data = json.loads(manifest.data) |
| 534 | + # TODO: BACKWARD COMPATIBILITY - remove after fully migrating to artifactless manifest |
| 535 | + elif saved_artifact := await manifest._artifacts.afirst(): |
| 536 | + content_data, _ = await sync_to_async(get_content_data)(saved_artifact) |
| 537 | + # if artifact is not available (due to reclaim space) we will download it again |
| 538 | + else: |
| 539 | + content_data, manifest = await self._download_and_instantiate_manifest( |
| 540 | + manifest_url, digest |
| 541 | + ) |
| 542 | + # END OF BACKWARD COMPATIBILITY |
| 543 | + else: |
| 544 | + content_data, manifest = await self._download_and_instantiate_manifest( |
| 545 | + manifest_url, digest |
| 546 | + ) |
516 | 547 |
|
517 | 548 | # in oci-index spec, platform is an optional field |
518 | 549 | platform = manifest_data.get("platform", None) |
@@ -603,7 +634,9 @@ async def create_signatures(self, man_dc, signature_source): |
603 | 634 | man_dc.content.digest, |
604 | 635 | ) |
605 | 636 | signatures_downloader = self.remote.get_downloader(url=signatures_url) |
606 | | - await signatures_downloader.run() |
| 637 | + # FIXME this can be rolledback after https://github.com/pulp/pulp_container/issues/1288 |
| 638 | + # signature extensions endpoint does not like any unnecessary headers to be sent |
| 639 | + await signatures_downloader.run(extra_data={"headers": {}}) |
607 | 640 | with open(signatures_downloader.path) as signatures_fd: |
608 | 641 | api_extension_signatures = json.loads(signatures_fd.read()) |
609 | 642 | for signature in api_extension_signatures.get("signatures", []): |
|
0 commit comments