diff --git a/data/model/tag.py b/data/model/tag.py index afc0b36cb..a392df2fd 100644 --- a/data/model/tag.py +++ b/data/model/tag.py @@ -223,7 +223,7 @@ def store_tag_manifest(namespace, repo_name, tag_name, docker_image_id, manifest return TagManifest.create(tag=tag, digest=manifest_digest, json_data=manifest_data) -def _get_active_tag(namespace, repo_name, tag_name): +def get_active_tag(namespace, repo_name, tag_name): return _tag_alive(RepositoryTag .select() .join(Image) @@ -235,7 +235,7 @@ def _get_active_tag(namespace, repo_name, tag_name): def associate_generated_tag_manifest(namespace, repo_name, tag_name, manifest_digest, manifest_data): - tag = _get_active_tag(namespace, repo_name, tag_name) + tag = get_active_tag(namespace, repo_name, tag_name) return TagManifest.create(tag=tag, digest=manifest_digest, json_data=manifest_data) diff --git a/endpoints/v2/manifest.py b/endpoints/v2/manifest.py index c5ceafeac..00b7696aa 100644 --- a/endpoints/v2/manifest.py +++ b/endpoints/v2/manifest.py @@ -17,6 +17,7 @@ from endpoints.trackhelper import track_and_log from endpoints.notificationhelper import spawn_notification from digest import digest_tools from data import model +from data.database import RepositoryTag logger = logging.getLogger(__name__) @@ -217,6 +218,11 @@ def fetch_manifest_by_tagname(namespace, repo_name, manifest_ref): try: manifest = model.tag.load_tag_manifest(namespace, repo_name, manifest_ref) except model.InvalidManifestException: + try: + model.tag.get_active_tag(namespace, repo_name, manifest_ref) + except RepositoryTag.DoesNotExist: + raise ManifestUnknown() + try: manifest = _generate_and_store_manifest(namespace, repo_name, manifest_ref) except model.DataModelException: