Merge "Raise 409 exception while deleting running container"

This commit is contained in:
Jenkins 2016-08-25 04:56:32 +00:00 committed by Gerrit Code Review
commit 3d34c84c2e
2 changed files with 9 additions and 0 deletions

View File

@ -339,3 +339,9 @@ class ContainerNotFound(HTTPNotFound):
class ContainerAlreadyExists(ResourceExists):
message = _("A container with UUID %(uuid)s already exists.")
class ContainerRunningException(ZunException):
message = _("The container %(id)s is running."
"Please stop and delete the container.")
code = 409

View File

@ -72,6 +72,9 @@ class Manager(object):
return container
except Exception as e:
LOG.exception(_LE("Unexpected exception: %s"), str(e))
if e.response.status_code == 409:
raise exception.ContainerRunningException(
id=container.container_id)
raise e
@translate_exception