Skip to content

Commit ce49327

Browse files
committed
Retry image download if it's corrupted
Adding IOError in list of catching exceptions in order to fix behavior when nova-compute wouldn't retry image download when got "Corrupt image download" error from glanceclient and had num_retries config option set. Closes-Bug: #1950657 Change-Id: Iae4fd0579f71d3ba6793dbdb037275352d7e57b0
1 parent 69b0d31 commit ce49327

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

nova/image/glance.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ def call(self, context, version, method, controller=None, args=None,
178178
kwargs = kwargs or {}
179179
retry_excs = (glanceclient.exc.ServiceUnavailable,
180180
glanceclient.exc.InvalidEndpoint,
181-
glanceclient.exc.CommunicationError)
181+
glanceclient.exc.CommunicationError,
182+
IOError)
182183
num_attempts = 1 + CONF.glance.num_retries
183184
controller_name = controller or 'images'
184185

nova/tests/unit/image/test_glance.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,20 @@ def test_default_client_with_retries(self, create_client_mock,
464464
client = glance.GlanceClientWrapper()
465465
self.assert_retry_attempted(sleep_mock, client, 'https://host2:9293')
466466

467+
@mock.patch('random.shuffle')
468+
@mock.patch('time.sleep')
469+
@mock.patch('nova.image.glance._glanceclient_from_endpoint')
470+
def test_retry_works_for_corrupted_image(self, create_client_mock,
471+
sleep_mock, shuffle_mock):
472+
side_effect = [
473+
IOError,
474+
None
475+
]
476+
self._mock_client_images_response(create_client_mock, side_effect)
477+
self.flags(num_retries=1, group='glance')
478+
client = glance.GlanceClientWrapper()
479+
self.assert_retry_attempted(sleep_mock, client, 'https://host2:9293')
480+
467481
@mock.patch('random.shuffle')
468482
@mock.patch('time.sleep')
469483
@mock.patch('nova.image.glance._glanceclient_from_endpoint')
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
fixes:
3+
- |
4+
`Bug 1950657 <https://bugs.launchpad.net/nova/+bug/1950657>`_, fixing
5+
behavior when nova-compute wouldn't retry image download when gets
6+
"Corrupt image download" error from glanceclient and has num_retries
7+
config option set.

0 commit comments

Comments
 (0)