Add an additional short circuit to avoid parsing the manifest when not necessary for older Docker clients
We also add tests for this case
This commit is contained in:
parent
7f068c3fc3
commit
e78b5c5516
3 changed files with 36 additions and 4 deletions
|
@ -15,7 +15,7 @@ from endpoints.v2 import v2_bp, require_repo_read, require_repo_write
|
|||
from endpoints.v2.errors import (ManifestInvalid, ManifestUnknown, NameInvalid, TagExpired,
|
||||
NameUnknown)
|
||||
from image.docker import ManifestException
|
||||
from image.docker.schema1 import DOCKER_SCHEMA1_MANIFEST_CONTENT_TYPE
|
||||
from image.docker.schema1 import DOCKER_SCHEMA1_MANIFEST_CONTENT_TYPE, DOCKER_SCHEMA1_CONTENT_TYPES
|
||||
from image.docker.schema2 import DOCKER_SCHEMA2_CONTENT_TYPES, OCI_CONTENT_TYPES
|
||||
from image.docker.schemas import parse_manifest_from_bytes
|
||||
from notifications import spawn_notification
|
||||
|
@ -113,6 +113,12 @@ def _rewrite_schema_if_necessary(namespace_name, repo_name, tag_name, manifest):
|
|||
if manifest.media_type in mimetypes:
|
||||
return manifest.internal_manifest_bytes, manifest.digest, manifest.media_type
|
||||
|
||||
# Short-circuit check: If the mimetypes is empty or just `application/json`, verify we have
|
||||
# a schema 1 manifest and return it.
|
||||
if not mimetypes or mimetypes == ['application/json']:
|
||||
if manifest.media_type in DOCKER_SCHEMA1_CONTENT_TYPES:
|
||||
return manifest.internal_manifest_bytes, manifest.digest, manifest.media_type
|
||||
|
||||
logger.debug('Manifest `%s` not compatible against %s; checking for conversion', manifest.digest,
|
||||
request.accept_mimetypes)
|
||||
converted = registry_model.convert_manifest(manifest, namespace_name, repo_name, tag_name,
|
||||
|
|
Reference in a new issue