From c1fa22d9b0c74964bf4171c42bbd7ec685ef9202 Mon Sep 17 00:00:00 2001 From: Quentin Machu Date: Wed, 4 Nov 2015 14:56:18 -0500 Subject: [PATCH 01/22] Define nginx v2 vhost & properly set 404 status code Fixes #777 --- conf/server-base.conf | 28 +++++++++++++++++++++------- endpoints/web.py | 11 ++++++----- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/conf/server-base.conf b/conf/server-base.conf index 05b66d180..5aa526f14 100644 --- a/conf/server-base.conf +++ b/conf/server-base.conf @@ -63,6 +63,27 @@ location /v1/ { client_max_body_size 20G; } +location /v1/_ping { + add_header Content-Type text/plain; + add_header X-Docker-Registry-Version 0.6.0; + add_header X-Docker-Registry-Standalone 0; + return 200 'true'; +} + +location /v2/ { + proxy_buffering off; + + proxy_request_buffering off; + + proxy_http_version 1.1; + proxy_set_header Connection ""; + + proxy_pass http://registry_app_server; + proxy_temp_path /tmp 1 2; + + client_max_body_size 20G; +} + location /c1/ { proxy_buffering off; @@ -80,13 +101,6 @@ location /static/ { error_page 404 /404; } -location /v1/_ping { - add_header Content-Type text/plain; - add_header X-Docker-Registry-Version 0.6.0; - add_header X-Docker-Registry-Standalone 0; - return 200 'true'; -} - location ~ ^/b1/controller(/?)(.*) { proxy_pass http://build_manager_controller_server/$2; } diff --git a/endpoints/web.py b/endpoints/web.py index da8ad2f05..4f0d0614a 100644 --- a/endpoints/web.py +++ b/endpoints/web.py @@ -58,11 +58,12 @@ def index(path, **kwargs): def internal_error_display(): return render_page_template('500.html') -#TODO: reenable once fixed -#@web.errorhandler(404) -#@web.route('/404', methods=['GET']) -#def not_found_error_display(e = None): -# return render_page_template('404.html') +@web.errorhandler(404) +@web.route('/404', methods=['GET']) +def not_found_error_display(e = None): + resp = render_page_template('404.html') + resp.status_code = 404 + return resp @web.route('/organization/', methods=['GET']) @no_cache From 4f41f79fa81e93ed2256de08d2af082514ddaea1 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 3 Nov 2015 18:15:23 -0500 Subject: [PATCH 02/22] 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 @@