diff options
| -rw-r--r-- | etc/nova/nova.conf.sample | 5 | ||||
| -rw-r--r-- | nova/tests/test_cinder.py | 17 | ||||
| -rw-r--r-- | nova/volume/cinder.py | 6 |
3 files changed, 23 insertions, 5 deletions
diff --git a/etc/nova/nova.conf.sample b/etc/nova/nova.conf.sample index c3c10239c..bee408412 100644 --- a/etc/nova/nova.conf.sample +++ b/etc/nova/nova.conf.sample @@ -1806,5 +1806,8 @@ #### (StrOpt) Override service catalog lookup with template for cinder #### endpoint e.g. http://localhost:8776/v1/%(project_id)s +# cinder_http_retries=3 +#### (IntOpt) Number of cinderclient retries on failed http calls -# Total option count: 462 + +# Total option count: 463 diff --git a/nova/tests/test_cinder.py b/nova/tests/test_cinder.py index dfdd4f3d7..7b1081b79 100644 --- a/nova/tests/test_cinder.py +++ b/nova/tests/test_cinder.py @@ -97,11 +97,14 @@ class FakeHTTPClient(cinder.cinder_client.client.HTTPClient): class FakeCinderClient(cinder.cinder_client.Client): - def __init__(self, username, password, project_id=None, auth_url=None): + def __init__(self, username, password, project_id=None, auth_url=None, + retries=None): super(FakeCinderClient, self).__init__(username, password, project_id=project_id, - auth_url=auth_url) - self.client = FakeHTTPClient(username, password, project_id, auth_url) + auth_url=auth_url, + retries=retries) + self.client = FakeHTTPClient(username, password, project_id, auth_url, + retries=retries) # keep a ref to the clients callstack for factory's assert_called self.callstack = self.client.callstack = [] @@ -173,3 +176,11 @@ class CinderTestCase(test.TestCase): self.assert_called('GET', '/volumes/5678') self.assertTrue('volume_image_metadata' in volume) self.assertEqual(volume['volume_image_metadata'], _image_metadata) + + def test_cinder_http_retries(self): + retries = 42 + self.flags(cinder_http_retries=retries) + volume = self.api.get(self.context, '1234') + self.assert_called('GET', '/volumes/1234') + self.assertEquals( + self.fake_client_factory.client.client.retries, retries) diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py index 04c151d1e..514295605 100644 --- a/nova/volume/cinder.py +++ b/nova/volume/cinder.py @@ -42,6 +42,9 @@ cinder_opts = [ default=None, help='Override service catalog lookup with template for cinder ' 'endpoint e.g. http://localhost:8776/v1/%(project_id)s'), + cfg.IntOpt('cinder_http_retries', + default=3, + help='Number of cinderclient retries on failed http calls'), ] CONF = cfg.CONF @@ -72,7 +75,8 @@ def cinderclient(context): c = cinder_client.Client(context.user_id, context.auth_token, project_id=context.project_id, - auth_url=url) + auth_url=url, + retries=CONF.cinder_http_retries) # noauth extracts user_id:project_id from auth_token c.client.auth_token = context.auth_token or '%s:%s' % (context.user_id, context.project_id) |
