diff --git a/nova/image/glance.py b/nova/image/glance.py index 870e1cd9a002..666bc30a66e1 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -178,7 +178,8 @@ class GlanceClientWrapper(object): kwargs = kwargs or {} retry_excs = (glanceclient.exc.ServiceUnavailable, glanceclient.exc.InvalidEndpoint, - glanceclient.exc.CommunicationError) + glanceclient.exc.CommunicationError, + IOError) num_attempts = 1 + CONF.glance.num_retries controller_name = controller or 'images' diff --git a/nova/tests/unit/image/test_glance.py b/nova/tests/unit/image/test_glance.py index 163a6ddc60b3..f8fbe3fbd183 100644 --- a/nova/tests/unit/image/test_glance.py +++ b/nova/tests/unit/image/test_glance.py @@ -464,6 +464,20 @@ class TestGlanceClientWrapperRetries(test.NoDBTestCase): client = glance.GlanceClientWrapper() self.assert_retry_attempted(sleep_mock, client, 'https://host2:9293') + @mock.patch('random.shuffle') + @mock.patch('time.sleep') + @mock.patch('nova.image.glance._glanceclient_from_endpoint') + def test_retry_works_for_corrupted_image(self, create_client_mock, + sleep_mock, shuffle_mock): + side_effect = [ + IOError, + None + ] + self._mock_client_images_response(create_client_mock, side_effect) + self.flags(num_retries=1, group='glance') + client = glance.GlanceClientWrapper() + self.assert_retry_attempted(sleep_mock, client, 'https://host2:9293') + @mock.patch('random.shuffle') @mock.patch('time.sleep') @mock.patch('nova.image.glance._glanceclient_from_endpoint') diff --git a/releasenotes/notes/bug-retry-corrupted-download-5798b0df44a00e4e.yaml b/releasenotes/notes/bug-retry-corrupted-download-5798b0df44a00e4e.yaml new file mode 100644 index 000000000000..e61132ec33fd --- /dev/null +++ b/releasenotes/notes/bug-retry-corrupted-download-5798b0df44a00e4e.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + `Bug 1950657 `_, fixing + behavior when nova-compute wouldn't retry image download when gets + "Corrupt image download" error from glanceclient and has num_retries + config option set.