Add client_socket_timeout option to manila.wsgi.Server
Add a parameter to take advantage of the eventlet socket timeout behaviour. Allows closing idle client connections after a period of time, eg: $ time nc localhost 8786 real 1m0.063s Setting 'client_socket_timeout = 0' means do not timeout. This is port of Cinder change - [1] [1] If492810a2f10fa5954f8c8bb708b14be0b77fb90 DocImpact Closes-bug: #1371022 Change-Id: I1da2a108c89ab292f9de66fce9cdc211ff5391a0
This commit is contained in:
parent
21eb376df5
commit
46538cd85c
|
@ -21,6 +21,7 @@ import ssl
|
|||
import tempfile
|
||||
import urllib2
|
||||
|
||||
import ddt
|
||||
import eventlet
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
|
@ -85,6 +86,7 @@ document_root = /tmp
|
|||
self.assertEqual("/tmp", url_parser.directory)
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class TestWSGIServer(test.TestCase):
|
||||
"""WSGI server tests."""
|
||||
|
||||
|
@ -141,10 +143,18 @@ class TestWSGIServer(test.TestCase):
|
|||
protocol=server._protocol,
|
||||
custom_pool=server._pool,
|
||||
log=server._logger,
|
||||
socket_timeout=server.client_socket_timeout,
|
||||
)
|
||||
|
||||
server.stop()
|
||||
|
||||
@ddt.data(0, 0.1, 1, None)
|
||||
def test_init_server_with_socket_timeout(self, client_socket_timeout):
|
||||
CONF.set_default("client_socket_timeout", client_socket_timeout)
|
||||
server = manila.wsgi.Server(
|
||||
"test_app", lambda *args, **kwargs: None, host="127.0.0.1", port=0)
|
||||
self.assertEqual(client_socket_timeout, server.client_socket_timeout)
|
||||
|
||||
def test_app_using_ssl(self):
|
||||
CONF.set_default("ssl_cert_file",
|
||||
os.path.join(TEST_VAR_DIR, 'certificate.crt'))
|
||||
|
|
|
@ -84,6 +84,12 @@ eventlet_opts = [
|
|||
"Option max_header_line may need to be increased when "
|
||||
"using large tokens (typically those generated by the "
|
||||
"Keystone v3 API with big service catalogs)."),
|
||||
cfg.IntOpt('client_socket_timeout',
|
||||
default=900,
|
||||
help="Timeout for client connections socket operations. "
|
||||
"If an incoming connection is idle for this number of "
|
||||
"seconds it will be closed. A value of '0' means "
|
||||
"wait forever."),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -111,6 +117,7 @@ class Server(service.ServiceBase):
|
|||
|
||||
"""
|
||||
eventlet.wsgi.MAX_HEADER_LINE = CONF.max_header_line
|
||||
self.client_socket_timeout = CONF.client_socket_timeout
|
||||
self.name = name
|
||||
self.app = app
|
||||
self._host = host or "0.0.0.0"
|
||||
|
@ -230,6 +237,7 @@ class Server(service.ServiceBase):
|
|||
'protocol': self._protocol,
|
||||
'custom_pool': self._pool,
|
||||
'log': self._logger,
|
||||
'socket_timeout': self.client_socket_timeout,
|
||||
}
|
||||
|
||||
self._server = eventlet.spawn(**wsgi_kwargs)
|
||||
|
|
Loading…
Reference in New Issue