[ARVADOS] created: 2aefffe61af4bb93659ca1cd9a9a027858658bec
Git user
git at public.curoverse.com
Mon Jul 25 16:33:23 EDT 2016
at 2aefffe61af4bb93659ca1cd9a9a027858658bec (commit)
commit 2aefffe61af4bb93659ca1cd9a9a027858658bec
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Mon Jul 25 17:32:46 2016 -0300
9551: Added support for env var ARVADOS_KEEP_SERVICES as a special case of a proxy.
diff --git a/sdk/python/arvados/keep.py b/sdk/python/arvados/keep.py
index 80633b7..5416379 100644
--- a/sdk/python/arvados/keep.py
+++ b/sdk/python/arvados/keep.py
@@ -678,7 +678,10 @@ class KeepClient(object):
put() are called. Default 0.
"""
self.lock = threading.Lock()
- if proxy is None:
+ if config.get('ARVADOS_KEEP_SERVICES'):
+ # ARVADOS_KEEP_SERVICES overrides proxy settings
+ proxy = config.get('ARVADOS_KEEP_SERVICES')
+ elif proxy is None:
proxy = config.get('ARVADOS_KEEP_PROXY')
if api_token is None:
if api_client is None:
@@ -710,15 +713,17 @@ class KeepClient(object):
self.num_retries = num_retries
self.max_replicas_per_service = None
if proxy:
- if not proxy.endswith('/'):
- proxy += '/'
+ proxy_uris = proxy.split(' ')
+ for i in range(len(proxy_uris)):
+ if not proxy_uris[i].endswith('/'):
+ proxy_uris[i] += '/'
self.api_token = api_token
self._gateway_services = {}
self._keep_services = [{
- 'uuid': 'proxy',
+ 'uuid': "00000-bi6l4-%015d" % proxy_uris.index(uri),
'service_type': 'proxy',
- '_service_root': proxy,
- }]
+ '_service_root': uri,
+ } for uri in proxy_uris]
self._writable_services = self._keep_services
self.using_proxy = True
self._static_services_list = True
diff --git a/sdk/python/tests/test_keep_client.py b/sdk/python/tests/test_keep_client.py
index 478f92f..9258aa5 100644
--- a/sdk/python/tests/test_keep_client.py
+++ b/sdk/python/tests/test_keep_client.py
@@ -270,6 +270,14 @@ class KeepProxyTestCase(run_test_server.TestCaseWithServers):
'wrong content from Keep.get(md5("baz2"))')
self.assertTrue(keep_client.using_proxy)
+ def test_KeepProxyTestMultipleURIs(self):
+ # Test using ARVADOS_KEEP_SERVICES env var overriding any
+ # existing proxy setting and setting multiple proxies
+ arvados.config.settings()['ARVADOS_KEEP_SERVICES'] = 'foo bar baz'
+ keep_client = arvados.KeepClient(api_client=self.api_client,
+ local_store='')
+ uris = [x['_service_root'] for x in keep_client._keep_services]
+ self.assertEqual(uris, ['foo/', 'bar/', 'baz/'])
class KeepClientServiceTestCase(unittest.TestCase, tutil.ApiClientMock):
def get_service_roots(self, api_client):
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list