Merge pull request #707 from coreos-inc/fixverbs

Fix verbs for merged changes to image and image storage
This commit is contained in:
josephschorr 2015-10-23 16:09:23 -04:00
commit a8cb59aa26

View file

@ -22,17 +22,14 @@ verbs = Blueprint('verbs', __name__)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def _open_stream(formatter, namespace, repository, tag, synthetic_image_id, image_json, def _open_stream(formatter, namespace, repository, tag, synthetic_image_id, image_json, repo_image):
image_id_list):
store = Storage(app) store = Storage(app)
# For performance reasons, we load the full image list here, cache it, then disconnect from # For performance reasons, we load the full image list here, cache it, then disconnect from
# the database. # the database.
with database.UseThenDisconnect(app.config): with database.UseThenDisconnect(app.config):
image_list = list(model.image.get_matching_repository_images(namespace, repository, image_list = list(model.image.get_parent_images(namespace, repository, repo_image))
image_id_list)) image_list.append(repo_image)
image_list.sort(key=lambda image: image_id_list.index(image.docker_image_id))
def get_next_image(): def get_next_image():
for current_image in image_list: for current_image in image_list:
@ -114,7 +111,7 @@ def _verify_repo_verb(store, namespace, repository, tag, verb, checker=None):
abort(404) abort(404)
# Lookup the tag's image and storage. # Lookup the tag's image and storage.
repo_image = model.image.get_repo_image(namespace, repository, tag_image.docker_image_id) repo_image = model.image.get_repo_image_extended(namespace, repository, tag_image.docker_image_id)
if not repo_image: if not repo_image:
abort(404) abort(404)
@ -186,8 +183,6 @@ def _repo_verb(namespace, repository, tag, verb, formatter, sign=False, checker=
uuid = repo_image.storage.uuid uuid = repo_image.storage.uuid
logger.debug('Building and returning derived %s image %s', verb, derived.uuid) logger.debug('Building and returning derived %s image %s', verb, derived.uuid)
ancestry_data = store.get_content(repo_image.storage.locations, store.image_ancestry_path(uuid))
full_image_list = json.loads(ancestry_data)
# Load the image's JSON layer. # Load the image's JSON layer.
if not image_json: if not image_json:
@ -202,7 +197,7 @@ def _repo_verb(namespace, repository, tag, verb, formatter, sign=False, checker=
# Create a queue process to generate the data. The queue files will read from the process # Create a queue process to generate the data. The queue files will read from the process
# and send the results to the client and storage. # and send the results to the client and storage.
args = (formatter, namespace, repository, tag, synthetic_image_id, image_json, full_image_list) args = (formatter, namespace, repository, tag, synthetic_image_id, image_json, repo_image)
queue_process = QueueProcess(_open_stream, queue_process = QueueProcess(_open_stream,
8 * 1024, 10 * 1024 * 1024, # 8K/10M chunk/max 8 * 1024, 10 * 1024 * 1024, # 8K/10M chunk/max
args, finished=_cleanup) args, finished=_cleanup)