Don't fix protocol-less glance api_servers anymore
Operators omitting the protocol (http(s)) from their [glance]api_servers value(s) have had long enough to fix it. Use it as is; and if the protocol is omitted, let it fail hard in the request. Change-Id: Ifebc9192e1e754180c97a3e40806c1c496a8b715
This commit is contained in:
parent
232458ae4e
commit
c56fc55170
@ -113,17 +113,8 @@ def get_api_servers():
|
|||||||
# NOTE(efried): utils.get_ksa_adapter().get_endpoint() is the preferred
|
# NOTE(efried): utils.get_ksa_adapter().get_endpoint() is the preferred
|
||||||
# mechanism for endpoint discovery. Only use `api_servers` if you really
|
# mechanism for endpoint discovery. Only use `api_servers` if you really
|
||||||
# need to shuffle multiple endpoints.
|
# need to shuffle multiple endpoints.
|
||||||
api_servers = []
|
|
||||||
if CONF.glance.api_servers:
|
if CONF.glance.api_servers:
|
||||||
for api_server in CONF.glance.api_servers:
|
api_servers = CONF.glance.api_servers
|
||||||
if '//' not in api_server:
|
|
||||||
api_server = 'http://' + api_server
|
|
||||||
# NOTE(sdague): remove in O.
|
|
||||||
LOG.warning("No protocol specified in for api_server '%s', "
|
|
||||||
"please update [glance] api_servers with fully "
|
|
||||||
"qualified url including scheme (http / https)",
|
|
||||||
api_server)
|
|
||||||
api_servers.append(api_server)
|
|
||||||
random.shuffle(api_servers)
|
random.shuffle(api_servers)
|
||||||
else:
|
else:
|
||||||
# TODO(efried): Plumb in a reasonable auth from callers' contexts
|
# TODO(efried): Plumb in a reasonable auth from callers' contexts
|
||||||
@ -131,8 +122,8 @@ def get_api_servers():
|
|||||||
nova.conf.glance.DEFAULT_SERVICE_TYPE,
|
nova.conf.glance.DEFAULT_SERVICE_TYPE,
|
||||||
min_version='2.0', max_version='2.latest')
|
min_version='2.0', max_version='2.latest')
|
||||||
# TODO(efried): Use ksa_adap.get_endpoint() when bug #1707995 is fixed.
|
# TODO(efried): Use ksa_adap.get_endpoint() when bug #1707995 is fixed.
|
||||||
api_servers.append(ksa_adap.endpoint_override or
|
api_servers = [ksa_adap.endpoint_override or
|
||||||
ksa_adap.get_endpoint_data().catalog_url)
|
ksa_adap.get_endpoint_data().catalog_url]
|
||||||
|
|
||||||
return itertools.cycle(api_servers)
|
return itertools.cycle(api_servers)
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ class TestGlanceClientWrapperRetries(test.NoDBTestCase):
|
|||||||
super(TestGlanceClientWrapperRetries, self).setUp()
|
super(TestGlanceClientWrapperRetries, self).setUp()
|
||||||
self.ctx = context.RequestContext('fake', 'fake')
|
self.ctx = context.RequestContext('fake', 'fake')
|
||||||
api_servers = [
|
api_servers = [
|
||||||
'host1:9292',
|
'http://host1:9292',
|
||||||
'https://host2:9293',
|
'https://host2:9293',
|
||||||
'http://host3:9294'
|
'http://host3:9294'
|
||||||
]
|
]
|
||||||
@ -1575,20 +1575,15 @@ class TestGlanceApiServers(test.NoDBTestCase):
|
|||||||
|
|
||||||
def test_get_api_servers_multiple(self):
|
def test_get_api_servers_multiple(self):
|
||||||
"""Test get_api_servers via `api_servers` conf option."""
|
"""Test get_api_servers via `api_servers` conf option."""
|
||||||
glance_servers = ['10.0.1.1:9292',
|
glance_servers = ['http://10.0.1.1:9292',
|
||||||
'https://10.0.0.1:9293',
|
|
||||||
'http://10.0.2.2:9294']
|
|
||||||
expected_servers = ['http://10.0.1.1:9292',
|
|
||||||
'https://10.0.0.1:9293',
|
'https://10.0.0.1:9293',
|
||||||
'http://10.0.2.2:9294']
|
'http://10.0.2.2:9294']
|
||||||
|
expected_servers = set(glance_servers)
|
||||||
self.flags(api_servers=glance_servers, group='glance')
|
self.flags(api_servers=glance_servers, group='glance')
|
||||||
api_servers = glance.get_api_servers()
|
api_servers = glance.get_api_servers()
|
||||||
i = 0
|
# In len(expected_servers) cycles, we should get all the endpoints
|
||||||
for server in api_servers:
|
self.assertEqual(expected_servers,
|
||||||
i += 1
|
{next(api_servers) for _ in expected_servers})
|
||||||
self.assertIn(server, expected_servers)
|
|
||||||
if i > 2:
|
|
||||||
break
|
|
||||||
|
|
||||||
@mock.patch('keystoneauth1.adapter.Adapter.get_endpoint_data')
|
@mock.patch('keystoneauth1.adapter.Adapter.get_endpoint_data')
|
||||||
def test_get_api_servers_get_ksa_adapter(self, mock_epd):
|
def test_get_api_servers_get_ksa_adapter(self, mock_epd):
|
||||||
|
@ -106,7 +106,7 @@ class TestGlanceStore(stubs.XenAPITestBaseNoDB):
|
|||||||
endpoint='http://10.0.0.1:9293',
|
endpoint='http://10.0.0.1:9293',
|
||||||
**params)]
|
**params)]
|
||||||
|
|
||||||
glance_api_servers = ['10.0.1.1:9292',
|
glance_api_servers = ['http://10.0.1.1:9292',
|
||||||
'http://10.0.0.1:9293']
|
'http://10.0.0.1:9293']
|
||||||
self.flags(api_servers=glance_api_servers, group='glance')
|
self.flags(api_servers=glance_api_servers, group='glance')
|
||||||
|
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
upgrade:
|
||||||
|
- |
|
||||||
|
If using the ``api_servers`` option in the ``[glance]`` configuration
|
||||||
|
section, the values therein must be URLs. Raw IP addresses will result
|
||||||
|
in hard failure of API requests.
|
Loading…
x
Reference in New Issue
Block a user