diff --git a/nova/conf/glance.py b/nova/conf/glance.py index 2f9683ff975c..c2c62a3c4dd6 100644 --- a/nova/conf/glance.py +++ b/nova/conf/glance.py @@ -25,7 +25,7 @@ glance_opts = [ # service catalog, however we don't have a good path there atm. # TODO(raj_singh): Add "required=True" flag to this option. cfg.ListOpt('api_servers', - help=""" + help=""" List of glance api servers endpoints available to nova. https is used for ssl-based glance api servers. @@ -36,25 +36,25 @@ Possible values: (i.e. "http://10.0.1.0:9292" or "https://my.glance.server/image"). """), cfg.BoolOpt('api_insecure', - default=False, - help=""" + default=False, + help=""" Enable insecure SSL (https) requests to glance. This setting can be used to turn off verification of the glance server certificate against the certificate authorities. """), -# TODO(raj_singh): Add min=0 flag in num_retries cfg.IntOpt('num_retries', - default=0, - help=""" + default=0, + min=0, + help=""" Enable glance operation retries. Specifies the number of retries when uploading / downloading an image to / from glance. 0 means no retries. """), cfg.ListOpt('allowed_direct_url_schemes', - default=[], - help=""" + default=[], + help=""" List of url schemes that can be directly accessed. This option specifies a list of url schemes that can be downloaded @@ -68,19 +68,19 @@ Possible values: * [file], Empty list (default) """), cfg.BoolOpt('use_glance_v1', - default=False, - deprecated_for_removal=True, - deprecated_since="14.0.0", - deprecated_reason='Glance v1 support will be removed in ' - 'Ocata', - help=""" + default=False, + deprecated_for_removal=True, + deprecated_since="14.0.0", + deprecated_reason='Glance v1 support will be removed in ' + 'Ocata', + help=""" This flag allows reverting to glance v1 if for some reason glance v2 doesn't work in your environment. This will only exist in Newton, and a fully working Glance v2 will be a hard requirement in Ocata. """), cfg.BoolOpt('verify_glance_signatures', - default=False, - help=""" + default=False, + help=""" Enable image signature verification. nova uses the image signature metadata from glance and verifies the signature @@ -96,8 +96,8 @@ Related options: for the signature validation. """), cfg.BoolOpt('debug', - default=False, - help='Enable or disable debug logging with glanceclient.') + default=False, + help='Enable or disable debug logging with glanceclient.') ] diff --git a/nova/image/glance.py b/nova/image/glance.py index 0a6ae5a468d8..3e060137661a 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -160,13 +160,7 @@ class GlanceClientWrapper(object): retry_excs = (glanceclient.exc.ServiceUnavailable, glanceclient.exc.InvalidEndpoint, glanceclient.exc.CommunicationError) - retries = CONF.glance.num_retries - if retries < 0: - LOG.warning(_LW("Treating negative config value (%(retries)s) for " - "'glance.num_retries' as 0."), - {'retries': retries}) - retries = 0 - num_attempts = retries + 1 + num_attempts = 1 + CONF.glance.num_retries for attempt in range(1, num_attempts + 1): client = self.client or self._create_onetime_client(context, diff --git a/nova/tests/unit/image/test_glance.py b/nova/tests/unit/image/test_glance.py index 91e30db1eee4..514fb0e92852 100644 --- a/nova/tests/unit/image/test_glance.py +++ b/nova/tests/unit/image/test_glance.py @@ -418,21 +418,6 @@ class TestGlanceClientWrapperRetries(test.NoDBTestCase): client = self._get_static_client(create_client_mock) self.assert_retry_not_attempted(sleep_mock, client) - @mock.patch('nova.image.glance.LOG') - @mock.patch('time.sleep') - @mock.patch('nova.image.glance._glanceclient_from_endpoint') - def test_static_client_with_retries_negative(self, create_client_mock, - sleep_mock, mock_log): - side_effect = glanceclient.exc.ServiceUnavailable - self._mock_client_images_response(create_client_mock, side_effect) - self.flags(num_retries=-1, group='glance') - client = self._get_static_client(create_client_mock) - self.assert_retry_not_attempted(sleep_mock, client) - - self.assertTrue(mock_log.warning.called) - msg = mock_log.warning.call_args_list[0] - self.assertIn('Treating negative config value', msg[0][0]) - @mock.patch('time.sleep') @mock.patch('nova.image.glance._glanceclient_from_endpoint') def test_static_client_with_retries(self, create_client_mock,