Only write exceptions for manifest gen when a tag exists

Fixes #1019

Currently, we just raise an exception to the logs regardless, which can make it appear as if there is an issue (when there isn't).
This commit is contained in:
Joseph Schorr 2015-12-03 16:04:17 -05:00
parent 597d6ecd3c
commit c324ebd7f6
2 changed files with 8 additions and 2 deletions

View file

@ -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)

View file

@ -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: