Add a check that will fail if we try to mislink V1 layers
Also logs some useful information
This commit is contained in:
parent
86584abba5
commit
27f1cc0a13
2 changed files with 10 additions and 2 deletions
|
@ -133,7 +133,8 @@ def invert_placement_query_results(placement_query):
|
|||
|
||||
def lookup_repository_images(repo, docker_image_ids):
|
||||
return (Image
|
||||
.select()
|
||||
.select(Image, ImageStorage)
|
||||
.join(ImageStorage) # TODO(jschorr): Remove once no longer needed in v2/manifest.py.
|
||||
.where(Image.repository == repo, Image.docker_image_id << docker_image_ids))
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import json
|
|||
import features
|
||||
|
||||
from peewee import IntegrityError
|
||||
from flask import make_response, request, url_for
|
||||
from flask import make_response, request, url_for, abort
|
||||
from collections import namedtuple, OrderedDict
|
||||
from jwkest.jws import SIGNER_ALGS, keyrep
|
||||
from datetime import datetime
|
||||
|
@ -373,6 +373,13 @@ def _write_manifest(namespace, repo_name, manifest):
|
|||
|
||||
# If there is already a V1 image for this layer, nothing more to do.
|
||||
if v1_mdata.docker_id in images_map:
|
||||
# Ensure that the V1 image's storage matches the V2 blob. If not, we've found
|
||||
# a data inconsistency and need to fail.
|
||||
v1_image = images_map[v1_mdata.docker_id]
|
||||
if v1_image.storage.content_checksum != digest_str:
|
||||
logger.error('Checksum mismatch on V1 layer %s (#%s): Expected digest %s, found %s',
|
||||
v1_mdata.docker_id, v1_image.id, digest_str, v1_image.storage.content_checksum)
|
||||
abort(500)
|
||||
continue
|
||||
|
||||
# Lookup the parent image for the layer, if any.
|
||||
|
|
Reference in a new issue