cinder-volume: Stop masking IOError different than ENOSPC
When glanceclient raises an IOError with a different errno than ENOSPC,
cinder-volume silently masked it and continued its volume creation
process. The result was volumes with invalid content being successfuly
created.
With the patch, an ImageDownloadFailed exception is raised in this case,
which makes the volume creation process fail and gives enough
information to operators for troubleshooting.
Change-Id: Ic011fe30b4840e5098db1a594ea276ec98768bff
Closes-Bug: #1799221
(cherry picked from commit 864c074ff1
)
This commit is contained in:
parent
1fcf54fd9f
commit
bf89f76fb1
|
@ -386,6 +386,12 @@ def fetch(context, image_service, image_id, path, _user_id, _project_id):
|
|||
raise exception.ImageTooBig(image_id=image_id,
|
||||
reason=reason)
|
||||
|
||||
reason = ("IOError: %(errno)s %(strerror)s" %
|
||||
{'errno': e.errno, 'strerror': e.strerror})
|
||||
LOG.error(reason)
|
||||
raise exception.ImageDownloadFailed(image_href=image_id,
|
||||
reason=reason)
|
||||
|
||||
duration = timeutils.delta_seconds(start_time, timeutils.utcnow())
|
||||
|
||||
# NOTE(jdg): use a default of 1, mostly for unit test, but in
|
||||
|
|
|
@ -348,6 +348,26 @@ class TestFetch(test.TestCase):
|
|||
context, image_service, image_id, path,
|
||||
_user_id, _project_id)
|
||||
|
||||
def test_fetch_ioerror(self):
|
||||
context = mock.sentinel.context
|
||||
image_service = mock.Mock()
|
||||
image_id = mock.sentinel.image_id
|
||||
e = IOError()
|
||||
e.errno = errno.ECONNRESET
|
||||
e.strerror = 'Some descriptive message'
|
||||
image_service.download.side_effect = e
|
||||
path = '/test_path'
|
||||
_user_id = mock.sentinel._user_id
|
||||
_project_id = mock.sentinel._project_id
|
||||
|
||||
with mock.patch('cinder.image.image_utils.open',
|
||||
new=mock.mock_open(), create=True):
|
||||
self.assertRaisesRegex(exception.ImageDownloadFailed,
|
||||
e.strerror,
|
||||
image_utils.fetch,
|
||||
context, image_service, image_id, path,
|
||||
_user_id, _project_id)
|
||||
|
||||
|
||||
class MockVerifier(object):
|
||||
def update(self, data):
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixed a bug which could create volumes with invalid content in case of
|
||||
unhandled errors from glance client
|
||||
(Bug `#1799221 <https://bugs.launchpad.net/cinder/+bug/1799221>`_).
|
Loading…
Reference in New Issue