Skip to content

Commit

Permalink
fix: image checks for some oci images failed
Browse files Browse the repository at this point in the history
This occurs because some images (most likely when they support multiple
architectures) have an index instead of just a manifest. An OCI index
refers to a set of images. But when we were checking for images we were
only checking for the manifest and did not have the option to support an
index content type.
  • Loading branch information
olevski committed Oct 16, 2024
1 parent f5a3381 commit aae7c56
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions renku_notebooks/api/classes/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

class ManifestTypes(Enum):
docker_v2: str = "application/vnd.docker.distribution.manifest.v2+json"
oci_v1: str = "application/vnd.oci.image.manifest.v1+json"
oci_v1_manifest: str = "application/vnd.oci.image.manifest.v1+json"
oci_v1_index: str = "application/vnd.oci.image.index.v1+json"


@dataclass
Expand Down Expand Up @@ -62,7 +63,10 @@ def get_image_manifest(self, image: "Image") -> Optional[dict[str, Any]]:
headers["Authorization"] = f"Bearer {token}"
res = requests.get(image_digest_url, headers=headers)
if res.status_code != 200:
headers["Accept"] = ManifestTypes.oci_v1.value
headers["Accept"] = ManifestTypes.oci_v1_manifest.value
res = requests.get(image_digest_url, headers=headers)
if res.status_code != 200:
headers["Accept"] = ManifestTypes.oci_v1_index.value
res = requests.get(image_digest_url, headers=headers)
if res.status_code != 200:
return None
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_public_image_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def test_public_image_name_parsing(name, expected):
("renku/singleuser", True),
("madeuprepo/madeupproject:tag", False),
("olevski90/oci-image:0.0.1", True),
("ghcr.io/linuxserver/nginx:latest", True)
],
)
@pytest.mark.integration
Expand Down

0 comments on commit aae7c56

Please sign in to comment.