diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-01-08 19:44:36 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-01-08 19:44:36 +0000 |
| commit | 885271e06e7860cca05d06d9f49ac0a2646684a8 (patch) | |
| tree | 1e80c1b5504aa6e3cf9f5421c3741d82f60d0f55 /nova | |
| parent | a02f22849aed77fd1e7fba3b0a3164e457e1d0f7 (diff) | |
| parent | dc8aeb49ce4ad6523e3f093fed082f78a6442814 (diff) | |
| download | nova-885271e06e7860cca05d06d9f49ac0a2646684a8.tar.gz nova-885271e06e7860cca05d06d9f49ac0a2646684a8.tar.xz nova-885271e06e7860cca05d06d9f49ac0a2646684a8.zip | |
Merge "Support cinderclient http retries."
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/tests/test_cinder.py | 17 | ||||
| -rw-r--r-- | nova/volume/cinder.py | 6 |
2 files changed, 19 insertions, 4 deletions
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) |
