diff options
author | Vu Tran <vu.tran@windriver.com> | 2016-08-29 16:33:19 -0400 |
---|---|---|
committer | Lee Yarwood <lyarwood@redhat.com> | 2021-03-25 12:00:00 +0000 |
commit | 9e9c022bde3a3ffdf0dd87e21bf9afde0dbc1e74 (patch) | |
tree | 785febfdf0ecc02e2be7badbbdb14a6cecffcde3 | |
parent | bf5f69697e218425128919ce0bde74e2ee699bc3 (diff) | |
download | nova-9e9c022bde3a3ffdf0dd87e21bf9afde0dbc1e74.tar.gz |
Improve error log when snapshot fails
If snapshot creation via glance fails due to lack of space or over
quota, we want to have a clearer error message.
Change-Id: Ic9133f6bc14d4fe766d37a438bf52c33e89da768
Closes-Bug: #1613770
(cherry picked from commit 024bf10d8aec5e58111793a9652b16682eb61b7c)
-rw-r--r-- | nova/exception.py | 5 | ||||
-rw-r--r-- | nova/image/glance.py | 2 | ||||
-rw-r--r-- | nova/tests/unit/image/test_glance.py | 5 |
3 files changed, 12 insertions, 0 deletions
diff --git a/nova/exception.py b/nova/exception.py index 7a5c523933..d1780349a5 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -620,6 +620,11 @@ class ImageBadRequest(Invalid): "%(response)s") +class ImageQuotaExceeded(NovaException): + msg_fmt = _("Quota exceeded or out of space for image %(image_id)s " + "in the image service.") + + class InstanceUnacceptable(Invalid): msg_fmt = _("Instance %(instance_id)s is unacceptable: %(reason)s") diff --git a/nova/image/glance.py b/nova/image/glance.py index b2c5f9ae05..5c25bd4e41 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -938,6 +938,8 @@ def _translate_image_exception(image_id, exc_value): if isinstance(exc_value, glanceclient.exc.BadRequest): return exception.ImageBadRequest(image_id=image_id, response=six.text_type(exc_value)) + if isinstance(exc_value, glanceclient.exc.HTTPOverLimit): + return exception.ImageQuotaExceeded(image_id=image_id) return exc_value diff --git a/nova/tests/unit/image/test_glance.py b/nova/tests/unit/image/test_glance.py index c5e714c1b0..59f5710d49 100644 --- a/nova/tests/unit/image/test_glance.py +++ b/nova/tests/unit/image/test_glance.py @@ -305,6 +305,11 @@ class TestExceptionTranslations(test.NoDBTestCase): out_exc = glance._translate_image_exception('123', in_exc) self.assertIsInstance(out_exc, exception.ImageNotFound) + def test_client_httpoverlimit_converts_to_imagequotaexceeded(self): + in_exc = glanceclient.exc.HTTPOverLimit('123') + out_exc = glance._translate_image_exception('123', in_exc) + self.assertIsInstance(out_exc, exception.ImageQuotaExceeded) + class TestGlanceSerializer(test.NoDBTestCase): def test_serialize(self): |