Allow configuring status_code_retries and connect_retries via cloud config
Change-Id: I45cf09f9aca8e4ed515a93e4903deb3df83ac65b
This commit is contained in:
parent
07d3828860
commit
46bb367ad6
@ -13,7 +13,7 @@ jmespath==0.9.0
|
|||||||
jsonpatch==1.16
|
jsonpatch==1.16
|
||||||
jsonpointer==1.13
|
jsonpointer==1.13
|
||||||
jsonschema==2.6.0
|
jsonschema==2.6.0
|
||||||
keystoneauth1==3.7.0
|
keystoneauth1==3.8.0
|
||||||
linecache2==1.0.0
|
linecache2==1.0.0
|
||||||
mock==2.0.0
|
mock==2.0.0
|
||||||
mox3==0.20.0
|
mox3==0.20.0
|
||||||
|
@ -207,7 +207,8 @@ class CloudRegion(object):
|
|||||||
def _get_config(
|
def _get_config(
|
||||||
self, key, service_type,
|
self, key, service_type,
|
||||||
default=None,
|
default=None,
|
||||||
fallback_to_unprefixed=False):
|
fallback_to_unprefixed=False,
|
||||||
|
converter=None):
|
||||||
'''Get a config value for a service_type.
|
'''Get a config value for a service_type.
|
||||||
|
|
||||||
Finds the config value for a key, looking first for it prefixed by
|
Finds the config value for a key, looking first for it prefixed by
|
||||||
@ -226,10 +227,17 @@ class CloudRegion(object):
|
|||||||
for st in self._service_type_manager.get_all_types(service_type):
|
for st in self._service_type_manager.get_all_types(service_type):
|
||||||
value = self.config.get(_make_key(key, st))
|
value = self.config.get(_make_key(key, st))
|
||||||
if value is not None:
|
if value is not None:
|
||||||
return value
|
break
|
||||||
if fallback_to_unprefixed:
|
else:
|
||||||
return self.config.get(key)
|
if fallback_to_unprefixed:
|
||||||
return default
|
value = self.config.get(key)
|
||||||
|
|
||||||
|
if value is None:
|
||||||
|
return default
|
||||||
|
else:
|
||||||
|
if converter is not None:
|
||||||
|
value = converter(value)
|
||||||
|
return value
|
||||||
|
|
||||||
def get_interface(self, service_type=None):
|
def get_interface(self, service_type=None):
|
||||||
return self._get_config(
|
return self._get_config(
|
||||||
@ -264,6 +272,16 @@ class CloudRegion(object):
|
|||||||
value = self._get_config('endpoint', service_type)
|
value = self._get_config('endpoint', service_type)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
def get_connect_retries(self, service_type):
|
||||||
|
return self._get_config('connect_retries', service_type,
|
||||||
|
fallback_to_unprefixed=True,
|
||||||
|
converter=int)
|
||||||
|
|
||||||
|
def get_status_code_retries(self, service_type):
|
||||||
|
return self._get_config('status_code_retries', service_type,
|
||||||
|
fallback_to_unprefixed=True,
|
||||||
|
converter=int)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def prefer_ipv6(self):
|
def prefer_ipv6(self):
|
||||||
return not self._force_ipv4
|
return not self._force_ipv4
|
||||||
@ -399,6 +417,11 @@ class CloudRegion(object):
|
|||||||
"""
|
"""
|
||||||
version_request = self._get_version_request(service_type, version)
|
version_request = self._get_version_request(service_type, version)
|
||||||
|
|
||||||
|
kwargs.setdefault('connect_retries',
|
||||||
|
self.get_connect_retries(service_type))
|
||||||
|
kwargs.setdefault('status_code_retries',
|
||||||
|
self.get_status_code_retries(service_type))
|
||||||
|
|
||||||
client = constructor(
|
client = constructor(
|
||||||
session=self.get_session(),
|
session=self.get_session(),
|
||||||
service_type=self.get_service_type(service_type),
|
service_type=self.get_service_type(service_type),
|
||||||
|
@ -34,6 +34,9 @@ fake_services_dict = {
|
|||||||
'identity_service_name': 'locks',
|
'identity_service_name': 'locks',
|
||||||
'volume_api_version': '1',
|
'volume_api_version': '1',
|
||||||
'auth': {'password': 'hunter2', 'username': 'AzureDiamond'},
|
'auth': {'password': 'hunter2', 'username': 'AzureDiamond'},
|
||||||
|
'connect_retries': 1,
|
||||||
|
'baremetal_status_code_retries': 5,
|
||||||
|
'baremetal_connect_retries': 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -149,6 +152,10 @@ class TestCloudRegion(base.TestCase):
|
|||||||
self.assertIsNone(cc.get_endpoint('image'))
|
self.assertIsNone(cc.get_endpoint('image'))
|
||||||
self.assertIsNone(cc.get_service_name('compute'))
|
self.assertIsNone(cc.get_service_name('compute'))
|
||||||
self.assertEqual('locks', cc.get_service_name('identity'))
|
self.assertEqual('locks', cc.get_service_name('identity'))
|
||||||
|
self.assertIsNone(cc.get_status_code_retries('compute'))
|
||||||
|
self.assertEqual(5, cc.get_status_code_retries('baremetal'))
|
||||||
|
self.assertEqual(1, cc.get_connect_retries('compute'))
|
||||||
|
self.assertEqual(3, cc.get_connect_retries('baremetal'))
|
||||||
|
|
||||||
def test_aliases(self):
|
def test_aliases(self):
|
||||||
services_dict = fake_services_dict.copy()
|
services_dict = fake_services_dict.copy()
|
||||||
|
7
releasenotes/notes/wire-in-retries-10898f7bc81e2269.yaml
Normal file
7
releasenotes/notes/wire-in-retries-10898f7bc81e2269.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Allows configuring Session's ``connect_retries`` and
|
||||||
|
``status_code_retries`` via the cloud configuration (options
|
||||||
|
``<service type>_connect_retries``, ``connect_retries``,
|
||||||
|
``<service type>_status_code_retries`` and ``status_code_retries``).
|
@ -8,7 +8,7 @@ requestsexceptions>=1.2.0 # Apache-2.0
|
|||||||
jsonpatch!=1.20,>=1.16 # BSD
|
jsonpatch!=1.20,>=1.16 # BSD
|
||||||
six>=1.10.0 # MIT
|
six>=1.10.0 # MIT
|
||||||
os-service-types>=1.2.0 # Apache-2.0
|
os-service-types>=1.2.0 # Apache-2.0
|
||||||
keystoneauth1>=3.7.0 # Apache-2.0
|
keystoneauth1>=3.8.0 # Apache-2.0
|
||||||
deprecation>=1.0 # Apache-2.0
|
deprecation>=1.0 # Apache-2.0
|
||||||
|
|
||||||
munch>=2.1.0 # MIT
|
munch>=2.1.0 # MIT
|
||||||
|
Loading…
Reference in New Issue
Block a user