Add new Manifest, ManifestLabel, ManifestLegacyImage and ManifestBlob tables and start writing and GCing to/from them
This change also starts passing in the manifest interface, rather than the raw data, to the model for writing. Note that this change does *not* backfill the existing rows in to the new tables; that will occur in a followup PR. The new columns in `tagmanifest` and `tagmanifestlabel` will be used to track the backfill, as it will occur in a worker.
This commit is contained in:
parent
36c7482385
commit
a46660a06f
13 changed files with 476 additions and 120 deletions
|
@ -191,8 +191,7 @@ def _write_manifest(namespace_name, repo_name, manifest):
|
|||
|
||||
# Store the manifest pointing to the tag.
|
||||
leaf_layer_id = rewritten_images[-1].image_id
|
||||
newly_created = model.save_manifest(repo, manifest.tag, leaf_layer_id, manifest.digest,
|
||||
manifest.bytes)
|
||||
newly_created = model.save_manifest(repo, manifest.tag, manifest, leaf_layer_id)
|
||||
if newly_created:
|
||||
# TODO: make this batch
|
||||
labels = []
|
||||
|
@ -279,6 +278,5 @@ def _generate_and_store_manifest(namespace_name, repo_name, tag_name):
|
|||
manifest = builder.build(docker_v2_signing_key)
|
||||
|
||||
# Write the manifest to the DB.
|
||||
model.create_manifest_and_update_tag(namespace_name, repo_name, tag_name, manifest.digest,
|
||||
manifest.bytes)
|
||||
model.create_manifest_and_update_tag(namespace_name, repo_name, tag_name, manifest)
|
||||
return manifest
|
||||
|
|
|
@ -138,11 +138,10 @@ class DockerRegistryV2DataInterface(object):
|
|||
pass
|
||||
|
||||
@abstractmethod
|
||||
def create_manifest_and_update_tag(self, namespace_name, repo_name, tag_name, manifest_digest,
|
||||
manifest_bytes):
|
||||
def create_manifest_and_update_tag(self, namespace_name, repo_name, tag_name, manifest):
|
||||
"""
|
||||
Creates a new manifest with the given digest and byte data, and assigns the tag with the given
|
||||
name under the matching repository to it.
|
||||
Creates a new manifest and assigns the tag with the given name under the matching repository to
|
||||
it.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
@ -156,11 +155,9 @@ class DockerRegistryV2DataInterface(object):
|
|||
pass
|
||||
|
||||
@abstractmethod
|
||||
def save_manifest(self, repository, tag_name, leaf_layer_docker_id, manifest_digest,
|
||||
manifest_bytes):
|
||||
def save_manifest(self, repository, tag_name, manifest):
|
||||
"""
|
||||
Saves a manifest pointing to the given leaf image, with the given manifest, under the matching
|
||||
repository as a tag with the given name.
|
||||
Saves a manifest, under the matching repository as a tag with the given name.
|
||||
|
||||
Returns a boolean whether or not the tag was newly created or not.
|
||||
"""
|
||||
|
|
|
@ -11,9 +11,10 @@ from endpoints.v2.models_interface import (
|
|||
RepositoryReference,
|
||||
Tag,)
|
||||
from image.docker.v1 import DockerV1Metadata
|
||||
from image.docker.interfaces import ManifestInterface
|
||||
from image.docker.schema1 import DOCKER_SCHEMA1_SIGNED_MANIFEST_CONTENT_TYPE
|
||||
|
||||
_MEDIA_TYPE = "application/vnd.docker.distribution.manifest.v1+prettyjws"
|
||||
|
||||
_MEDIA_TYPE = DOCKER_SCHEMA1_SIGNED_MANIFEST_CONTENT_TYPE
|
||||
|
||||
class PreOCIModel(DockerRegistryV2DataInterface):
|
||||
"""
|
||||
|
@ -90,11 +91,10 @@ class PreOCIModel(DockerRegistryV2DataInterface):
|
|||
parents = model.image.get_parent_images(namespace_name, repo_name, repo_image)
|
||||
return [_docker_v1_metadata(namespace_name, repo_name, image) for image in parents]
|
||||
|
||||
def create_manifest_and_update_tag(self, namespace_name, repo_name, tag_name, manifest_digest,
|
||||
manifest_bytes):
|
||||
def create_manifest_and_update_tag(self, namespace_name, repo_name, tag_name, manifest):
|
||||
assert isinstance(manifest, ManifestInterface)
|
||||
try:
|
||||
model.tag.associate_generated_tag_manifest(namespace_name, repo_name, tag_name,
|
||||
manifest_digest, manifest_bytes)
|
||||
model.tag.associate_generated_tag_manifest(namespace_name, repo_name, tag_name, manifest)
|
||||
except IntegrityError:
|
||||
# It's already there!
|
||||
pass
|
||||
|
@ -112,10 +112,10 @@ class PreOCIModel(DockerRegistryV2DataInterface):
|
|||
parent_image)
|
||||
return _docker_v1_metadata(repository.namespace_name, repository.name, repo_image)
|
||||
|
||||
def save_manifest(self, repository, tag_name, leaf_layer_docker_id, manifest_digest,
|
||||
manifest_bytes):
|
||||
(_, newly_created) = model.tag.store_tag_manifest_for_repo(
|
||||
repository.id, tag_name, leaf_layer_docker_id, manifest_digest, manifest_bytes)
|
||||
def save_manifest(self, repository, tag_name, manifest, leaf_layer_id=None):
|
||||
assert isinstance(manifest, ManifestInterface)
|
||||
(_, newly_created) = model.tag.store_tag_manifest_for_repo(repository.id, tag_name, manifest,
|
||||
leaf_layer_id=leaf_layer_id)
|
||||
return newly_created
|
||||
|
||||
def repository_tags(self, namespace_name, repo_name, start_id, limit):
|
||||
|
|
Reference in a new issue