Change tag history call in OCI to not load the contents of the manifest
Just in case that load is slow on the DB
This commit is contained in:
parent
0d6343871e
commit
2027d13d2b
3 changed files with 8 additions and 6 deletions
|
@ -78,10 +78,11 @@ def list_repository_tag_history(repository_id, page, page_size, specific_tag_nam
|
|||
active_tags_only=False):
|
||||
""" Returns a tuple of the full set of tags found in the specified repository, including those
|
||||
that are no longer alive (unless active_tags_only is True), and whether additional tags exist.
|
||||
If specific_tag_name is given, the tags are further filtered by name.
|
||||
If specific_tag_name is given, the tags are further filtered by name. Note that the
|
||||
returned Manifest will not contain the manifest contents.
|
||||
"""
|
||||
query = (Tag
|
||||
.select(Tag, Manifest)
|
||||
.select(Tag, Manifest.id, Manifest.digest, Manifest.media_type)
|
||||
.join(Manifest)
|
||||
.where(Tag.repository == repository_id)
|
||||
.order_by(Tag.lifetime_start_ms.desc(), Tag.name)
|
||||
|
|
|
@ -217,9 +217,12 @@ class Manifest(datatype('Manifest', ['digest', 'media_type', 'internal_manifest_
|
|||
if manifest is None:
|
||||
return None
|
||||
|
||||
# NOTE: `manifest_bytes` will be None if not selected by certain join queries.
|
||||
manifest_bytes = (Bytes.for_string_or_unicode(manifest.manifest_bytes)
|
||||
if manifest.manifest_bytes is not None else None)
|
||||
return Manifest(db_id=manifest.id,
|
||||
digest=manifest.digest,
|
||||
internal_manifest_bytes=Bytes.for_string_or_unicode(manifest.manifest_bytes),
|
||||
internal_manifest_bytes=manifest_bytes,
|
||||
media_type=ManifestTable.media_type.get_name(manifest.media_type_id),
|
||||
inputs=dict(legacy_image=legacy_image, tag_manifest=False))
|
||||
|
||||
|
@ -245,6 +248,7 @@ class Manifest(datatype('Manifest', ['digest', 'media_type', 'internal_manifest_
|
|||
|
||||
def get_parsed_manifest(self, validate=True):
|
||||
""" Returns the parsed manifest for this manifest. """
|
||||
assert self.internal_manifest_bytes
|
||||
return parse_manifest_from_bytes(self.internal_manifest_bytes, self.media_type,
|
||||
validate=validate)
|
||||
|
||||
|
|
|
@ -41,9 +41,6 @@ def _tag_dict(tag):
|
|||
if tag.manifest:
|
||||
tag_info['is_manifest_list'] = tag.manifest.is_manifest_list
|
||||
|
||||
if 'size' not in tag_info:
|
||||
tag_info['size'] = tag.manifest.layers_compressed_size
|
||||
|
||||
if tag.lifetime_start_ts > 0:
|
||||
last_modified = format_date(datetime.utcfromtimestamp(tag.lifetime_start_ts))
|
||||
tag_info['last_modified'] = last_modified
|
||||
|
|
Reference in a new issue