Handle IntegrityError in tag update code
Fixes https://sentry.io/coreos/backend-production/issues/173470565/events/4938537230/
This commit is contained in:
parent
9db20ff961
commit
d29d2da1ca
2 changed files with 7 additions and 1 deletions
|
@ -96,6 +96,9 @@ class ServiceNameInvalid(DataModelException):
|
|||
class TagAlreadyCreatedException(DataModelException):
|
||||
pass
|
||||
|
||||
class StaleTagException(DataModelException):
|
||||
pass
|
||||
|
||||
|
||||
class TooManyLoginAttemptsException(Exception):
|
||||
def __init__(self, message, retry_after):
|
||||
|
|
|
@ -4,7 +4,7 @@ from uuid import uuid4
|
|||
|
||||
from peewee import IntegrityError
|
||||
from data.model import (image, db_transaction, DataModelException, _basequery,
|
||||
InvalidManifestException, TagAlreadyCreatedException)
|
||||
InvalidManifestException, TagAlreadyCreatedException, StaleTagException)
|
||||
from data.database import (RepositoryTag, Repository, Image, ImageStorage, Namespace, TagManifest,
|
||||
RepositoryNotification, Label, TagManifestLabel, get_epoch_timestamp,
|
||||
db_for_update)
|
||||
|
@ -92,6 +92,9 @@ def create_or_update_tag(namespace_name, repository_name, tag_name, tag_docker_i
|
|||
tag.save()
|
||||
except RepositoryTag.DoesNotExist:
|
||||
pass
|
||||
except IntegrityError:
|
||||
msg = 'Tag with name %s was stale when we tried to update it; Please retry the push'
|
||||
raise StaleTagException(msg % tag_name)
|
||||
|
||||
try:
|
||||
image_obj = Image.get(Image.docker_image_id == tag_docker_image_id, Image.repository == repo)
|
||||
|
|
Reference in a new issue