diff --git a/zun/common/exception.py b/zun/common/exception.py index 71b072681..5245862d3 100644 --- a/zun/common/exception.py +++ b/zun/common/exception.py @@ -346,7 +346,7 @@ class ContainerAlreadyExists(ResourceExists): class ImageAlreadyExists(ResourceExists): - message = _("An image with this tag and repo already exists.") + message = _("An image with tag %(tag)s and repo %(repo)s already exists.") class InvalidStateException(ZunException): diff --git a/zun/db/sqlalchemy/api.py b/zun/db/sqlalchemy/api.py index 653ad3d2f..44c95e34c 100644 --- a/zun/db/sqlalchemy/api.py +++ b/zun/db/sqlalchemy/api.py @@ -279,7 +279,8 @@ class Connection(api.Connection): try: image.save() except db_exc.DBDuplicateEntry: - raise exception.ImageAlreadyExists() + raise exception.ImageAlreadyExists(tag=values['tag'], + repo=values['repo']) return image def update_image(self, image_id, values): diff --git a/zun/tests/unit/api/controllers/v1/test_images.py b/zun/tests/unit/api/controllers/v1/test_images.py index 0d78634fe..6c8965e9c 100644 --- a/zun/tests/unit/api/controllers/v1/test_images.py +++ b/zun/tests/unit/api/controllers/v1/test_images.py @@ -118,6 +118,7 @@ class TestImageController(api_base.FunctionalTest): for id_ in range(4): test_image = utils.create_test_image( id=id_, + repo='testrepo' + str(id_), uuid=comm_utils.generate_uuid()) image_list.append(objects.Image(self.context, **test_image)) mock_image_list.return_value = image_list[-1:]