summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCory Stone <corystone@gmail.com>2012-11-16 14:15:06 -0600
committerCory Stone <corystone@gmail.com>2013-01-07 14:57:27 -0600
commitdc8aeb49ce4ad6523e3f093fed082f78a6442814 (patch)
tree79c4f459a2dbe200dcb10c8125a52bf0740a8e0d
parente1c7b18c7f3c8d97ba7b2cccf27b968ad4710735 (diff)
Support cinderclient http retries.
HTTP retries were recently added to cinderclient. This adds the config option required to use it. The default (unchanged) behavior is 0 retries. Change-Id: Ia7ad831045e8df9ad9c22f0119ae3485d91ad949
-rw-r--r--etc/nova/nova.conf.sample5
-rw-r--r--nova/tests/test_cinder.py17
-rw-r--r--nova/volume/cinder.py6
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)