From accb273c7aa369f624e8062137b356dc3e5589cf Mon Sep 17 00:00:00 2001 From: Valeriy Ponomaryov Date: Wed, 22 Jul 2015 20:30:42 +0300 Subject: [PATCH] Eventlet green threads not released back to pool Presently, the wsgi server allows persist connections hence even after the response is sent to the client, it doesn't close the client socket connection. Because of this problem, the green thread is not released back to the pool. In order to close the client socket connection explicitly after the response is sent and read successfully by the client, you simply have to set keepalive to False when you create a wsgi server. DocImpact: Added wsgi_keep_alive option (default=True). In order to maintain the backward compatibility, setting wsgi_keep_alive as True by default. Recommended is set it to False. This is port of Cinder change - [1] [1] Ic57b2aceb136e8626388cfe4df72b2f47cb0661c SecurityImpact Closes-Bug: #1361360 Change-Id: If9241e6f6ba10592a64ca312cb479e8cea929913 --- devstack/plugin.sh | 2 ++ manila/tests/test_wsgi.py | 1 + manila/wsgi.py | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 94ded8c9d9..eefe5584d6 100755 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -261,6 +261,8 @@ function configure_manila { iniset $MANILA_CONF oslo_concurrency lock_path $MANILA_LOCK_PATH + iniset $MANILA_CONF DEFAULT wsgi_keep_alive False + # Note: set up config group does not mean that this backend will be enabled. # To enable it, specify its name explicitly using "enabled_share_backends" opt. configure_default_backends diff --git a/manila/tests/test_wsgi.py b/manila/tests/test_wsgi.py index fd41b10798..c7e9c503c0 100644 --- a/manila/tests/test_wsgi.py +++ b/manila/tests/test_wsgi.py @@ -144,6 +144,7 @@ class TestWSGIServer(test.TestCase): custom_pool=server._pool, log=server._logger, socket_timeout=server.client_socket_timeout, + keepalive=manila.wsgi.CONF.wsgi_keep_alive, ) server.stop() diff --git a/manila/wsgi.py b/manila/wsgi.py index 71d566f652..daadf0c981 100644 --- a/manila/wsgi.py +++ b/manila/wsgi.py @@ -90,6 +90,11 @@ eventlet_opts = [ "If an incoming connection is idle for this number of " "seconds it will be closed. A value of '0' means " "wait forever."), + cfg.BoolOpt('wsgi_keep_alive', + default=True, + help='If False, closes the client socket connection ' + 'explicitly. Setting it to True to maintain backward ' + 'compatibility. Recommended setting is set it to False.'), ] CONF = cfg.CONF @@ -238,6 +243,7 @@ class Server(service.ServiceBase): 'custom_pool': self._pool, 'log': self._logger, 'socket_timeout': self.client_socket_timeout, + 'keepalive': CONF.wsgi_keep_alive, } self._server = eventlet.spawn(**wsgi_kwargs)