Added timeout to bufferedhttp class and timeout setting for middleware - bug 891687
Change-Id: Ib3f30ac6b78c5064ad2eb6257f8739a75b629fa3
This commit is contained in:
parent
ebb00b49d1
commit
1a3b810f70
|
@ -6,8 +6,9 @@ paste.app_factory = auth_token:app_factory
|
|||
auth_protocol = http
|
||||
auth_host = 127.0.0.1
|
||||
auth_port = 35357
|
||||
auth_uri = http://127.0.0.1:5000/
|
||||
auth_uri = http://127.0.0.1:35357/
|
||||
admin_token = 999888777666
|
||||
auth_timeout = 10
|
||||
|
||||
delay_auth_decision = 1
|
||||
|
||||
|
@ -15,5 +16,5 @@ service_protocol = http
|
|||
service_host = 127.0.0.1
|
||||
service_port = 8100
|
||||
service_pass = dTpw
|
||||
|
||||
service_timeout = 120
|
||||
|
||||
|
|
|
@ -165,3 +165,4 @@ auth_port = 35357
|
|||
auth_protocol = http
|
||||
auth_uri = http://127.0.0.1:5000/
|
||||
admin_token = 999888777666
|
||||
auth_timeout = 30
|
||||
|
|
|
@ -60,6 +60,7 @@ auth_port = 35357
|
|||
auth_protocol = http
|
||||
auth_uri = http://127.0.0.1:5000/
|
||||
admin_token = 999888777666
|
||||
auth_timeout = 30
|
||||
|
||||
[filter:keystone_shim]
|
||||
paste.filter_factory = keystone.middleware.glance_auth_token:filter_factory
|
||||
|
|
|
@ -125,3 +125,4 @@ auth_port = 35357
|
|||
auth_protocol = http
|
||||
auth_uri = http://127.0.0.1:5000/
|
||||
admin_token = 999888777666
|
||||
auth_timeout = 30
|
||||
|
|
|
@ -33,6 +33,8 @@ import time
|
|||
from eventlet.green.httplib import CONTINUE, HTTPConnection, HTTPMessage, \
|
||||
HTTPResponse, HTTPSConnection, _UNKNOWN
|
||||
|
||||
DEFAULT_TIMEOUT = 30
|
||||
|
||||
|
||||
class BufferedHTTPResponse(HTTPResponse):
|
||||
"""HTTPResponse class that buffers reading of headers"""
|
||||
|
@ -102,7 +104,7 @@ class BufferedHTTPConnection(HTTPConnection):
|
|||
|
||||
def http_connect(ipaddr, port, device, partition, method, path,
|
||||
headers=None, query_string=None, ssl=False, key_file=None,
|
||||
cert_file=None):
|
||||
cert_file=None, timeout=None):
|
||||
"""
|
||||
Helper function to create an HTTPConnection object. If ssl is set True,
|
||||
HTTPSConnection will be used. However, if ssl=False, BufferedHTTPConnection
|
||||
|
@ -123,12 +125,13 @@ def http_connect(ipaddr, port, device, partition, method, path,
|
|||
"""
|
||||
path = quote('/' + device + '/' + str(partition) + path)
|
||||
return http_connect_raw(ipaddr, port, device, partition, method, path,
|
||||
headers, query_string, ssl, key_file, cert_file)
|
||||
headers, query_string, ssl, key_file, cert_file,
|
||||
timeout=timeout)
|
||||
|
||||
|
||||
def http_connect_raw(ipaddr, port, method, path, headers=None,
|
||||
query_string=None, ssl=False, key_file=None,
|
||||
cert_file=None):
|
||||
cert_file=None, timeout=None):
|
||||
"""
|
||||
Helper function to create an HTTPConnection object. If ssl is set True,
|
||||
HTTPSConnection will be used. However, if ssl=False, BufferedHTTPConnection
|
||||
|
@ -145,11 +148,14 @@ def http_connect_raw(ipaddr, port, method, path, headers=None,
|
|||
:param cert_file Certificate file (Keystore)
|
||||
:returns: HTTPConnection object
|
||||
"""
|
||||
if timeout is None:
|
||||
timeout = DEFAULT_TIMEOUT
|
||||
if ssl:
|
||||
conn = HTTPSConnection('%s:%s' % (ipaddr, port), key_file=key_file,
|
||||
cert_file=cert_file)
|
||||
cert_file=cert_file, timeout=timeout)
|
||||
else:
|
||||
conn = BufferedHTTPConnection('%s:%s' % (ipaddr, port))
|
||||
conn = BufferedHTTPConnection('%s:%s' % (ipaddr, port),
|
||||
timeout=timeout)
|
||||
if query_string:
|
||||
path += '?' + query_string
|
||||
conn.path = path
|
||||
|
|
|
@ -139,6 +139,7 @@ class AuthProtocol(object):
|
|||
self.service_url = '%s://%s:%s' % (self.service_protocol,
|
||||
self.service_host,
|
||||
self.service_port)
|
||||
self.service_timeout = conf.get('service_timeout', 30)
|
||||
# used to verify this component with the OpenStack service or PAPIAuth
|
||||
self.service_pass = conf.get('service_pass')
|
||||
|
||||
|
@ -153,6 +154,7 @@ class AuthProtocol(object):
|
|||
self.auth_host = conf.get('auth_host')
|
||||
self.auth_port = int(conf.get('auth_port'))
|
||||
self.auth_protocol = conf.get('auth_protocol', 'https')
|
||||
self.auth_timeout = conf.get('auth_timeout', 30)
|
||||
|
||||
# where to tell clients to find the auth service (default to url
|
||||
# constructed based on endpoint we have for the service to use)
|
||||
|
@ -305,7 +307,8 @@ class AuthProtocol(object):
|
|||
conn = http_connect(self.auth_host, self.auth_port, 'GET',
|
||||
'/v2.0/tokens/%s' % claims, headers=headers,
|
||||
ssl=(self.auth_protocol == 'https'),
|
||||
key_file=self.key_file, cert_file=self.cert_file)
|
||||
key_file=self.key_file, cert_file=self.cert_file,
|
||||
timeout=self.auth_timeout)
|
||||
resp = conn.getresponse()
|
||||
data = resp.read()
|
||||
conn.close()
|
||||
|
@ -367,7 +370,8 @@ class AuthProtocol(object):
|
|||
req.method,
|
||||
parsed.path,
|
||||
proxy_headers,
|
||||
ssl=(self.service_protocol == 'https'))
|
||||
ssl=(self.service_protocol == 'https'),
|
||||
timeout=self.service_timeout)
|
||||
resp = conn.getresponse()
|
||||
data = resp.read()
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ class AuthProtocol(object):
|
|||
self.keystone_url = urlparse(conf.get('keystone_url'))
|
||||
self.keystone_admin_group = conf.get('keystone_admin_group', 'Admin')
|
||||
self.admin_token = conf.get('keystone_admin_token')
|
||||
self.auth_timeout = conf.get('keystone_auth_timeout', 30)
|
||||
self.allowed_sync_hosts = [h.strip()
|
||||
for h in conf.get('allowed_sync_hosts', '127.0.0.1').split(',')
|
||||
if h.strip()]
|
||||
|
@ -135,7 +136,8 @@ class AuthProtocol(object):
|
|||
(self.keystone_url.path,
|
||||
quote(claim)),
|
||||
headers=headers,
|
||||
ssl=(self.keystone_url.scheme == 'https'))
|
||||
ssl=(self.keystone_url.scheme == 'https'),
|
||||
timeout=self.auth_timeout)
|
||||
resp = conn.getresponse()
|
||||
data = resp.read()
|
||||
conn.close()
|
||||
|
|
Loading…
Reference in New Issue