From 70508e3692a91f1b808ba0ce94a98487029b62af Mon Sep 17 00:00:00 2001 From: EvB Date: Tue, 2 May 2017 16:13:21 -0400 Subject: [PATCH] feat(api/tag): generate manifest on revert_tag action --- endpoints/api/tag.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/endpoints/api/tag.py b/endpoints/api/tag.py index 9e928df93..d3c6352c7 100644 --- a/endpoints/api/tag.py +++ b/endpoints/api/tag.py @@ -230,12 +230,8 @@ class RestoreTag(RepositoryParamResource): # Restore the tag back to the previous image. image_id = request.get_json()['image'] manifest_digest = request.get_json().get('manifest_digest', None) - if manifest_digest is not None: - existing_image = model.tag.restore_tag_to_manifest(repo, tag, manifest_digest) - else: - existing_image = model.tag.restore_tag_to_image(repo, tag, image_id) - # Log the reversion/restoration. + # Data for logging the reversion/restoration. username = get_authenticated_user().username log_data = { 'username': username, @@ -244,6 +240,17 @@ class RestoreTag(RepositoryParamResource): 'image': image_id, } + if manifest_digest is not None: + existing_image = model.tag.restore_tag_to_manifest(repo, tag, manifest_digest) + else: + existing_image = model.tag.restore_tag_to_image(repo, tag, image_id) + try: + _generate_and_store_manifest(namespace, repository, tag) + except: + # log and move on since we'll attempt to store manifest on first pull as well + logger.exception('unable to store manifest for tag', extra=log_data) + + if existing_image is not None: log_data['original_image'] = existing_image.docker_image_id