From 4f41f79fa81e93ed2256de08d2af082514ddaea1 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 3 Nov 2015 18:15:23 -0500 Subject: [PATCH] Never load the full repo image list Always make smaller queries per tag to ensure we scale better Fixes #754 --- endpoints/api/tag.py | 31 ++++- static/directives/image-info-sidebar.html | 8 +- .../repo-view/repo-panel-changes.html | 71 ++++++----- .../directives/repo-view/repo-panel-tags.html | 2 +- static/directives/tag-operations-dialog.html | 8 +- .../directives/tag-specific-images-view.html | 6 +- .../repo-view/repo-panel-changes.js | 39 ++++--- .../directives/repo-view/repo-panel-tags.js | 2 +- static/js/directives/ui/image-info-sidebar.js | 5 + .../js/directives/ui/tag-operations-dialog.js | 110 +++++------------- .../directives/ui/tag-specific-image-view.js | 80 ++----------- static/js/graphing.js | 14 ++- static/js/pages/repo-view.js | 26 +---- static/js/services/image-loader-service.js | 110 ++++++++++++++++++ static/partials/repo-view.html | 10 +- 15 files changed, 268 insertions(+), 254 deletions(-) create mode 100644 static/js/services/image-loader-service.js diff --git a/endpoints/api/tag.py b/endpoints/api/tag.py index b657e5827..4233144ef 100644 --- a/endpoints/api/tag.py +++ b/endpoints/api/tag.py @@ -4,7 +4,7 @@ from flask import request, abort from endpoints.api import (resource, nickname, require_repo_read, require_repo_write, RepositoryParamResource, log_action, NotFound, validate_json_request, - path_param, parse_args, query_param) + path_param, parse_args, query_param, truthy_bool) from endpoints.api.image import image_view from data import model from auth.auth_context import get_authenticated_user @@ -135,7 +135,10 @@ class RepositoryTagImages(RepositoryParamResource): """ Resource for listing the images in a specific repository tag. """ @require_repo_read @nickname('listTagImages') - def get(self, namespace, repository, tag): + @parse_args + @query_param('owned', 'If specified, only images wholely owned by this tag are returned.', + type=truthy_bool, default=False) + def get(self, args, namespace, repository, tag): """ List the images for the specified repository tag. """ try: tag_image = model.tag.get_tag_image(namespace, repository, tag) @@ -144,15 +147,37 @@ class RepositoryTagImages(RepositoryParamResource): parent_images = model.image.get_parent_images(namespace, repository, tag_image) image_map = {} + + image_map[str(tag_image.id)] = tag_image + for image in parent_images: image_map[str(image.id)] = image + image_map_all = dict(image_map) + parents = list(parent_images) parents.reverse() all_images = [tag_image] + parents + # Filter the images returned to those not found in the ancestry of any of the other tags in + # the repository. + if args['owned']: + all_tags = model.tag.list_repository_tags(namespace, repository) + for current_tag in all_tags: + if current_tag.name == tag: + continue + + # Remove the tag's image ID. + tag_image_id = str(current_tag.image_id) + image_map.pop(tag_image_id, None) + + # Remove any ancestors: + for ancestor_id in current_tag.image.ancestors.split('/'): + image_map.pop(ancestor_id, None) + return { - 'images': [image_view(image, image_map) for image in all_images] + 'images': [image_view(image, image_map_all) for image in all_images + if not args['owned'] or (str(image.id) in image_map)] } diff --git a/static/directives/image-info-sidebar.html b/static/directives/image-info-sidebar.html index 657aac6db..a126c88ca 100644 --- a/static/directives/image-info-sidebar.html +++ b/static/directives/image-info-sidebar.html @@ -20,14 +20,14 @@