summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-06-12 10:06:47 +0000
committerGerrit Code Review <review@openstack.org>2015-06-12 10:06:47 +0000
commit308afbe015faf7b35ac1087db7ecf65aca92107a (patch)
treeab12d693068e3a086db9524e5a38cc4070635426
parent8566798c05b84fb411da5607ee5da3f79961960e (diff)
parentd569ed9db9dc1941ef74d38f85f8f67a85ff10b0 (diff)
downloadglance-308afbe015faf7b35ac1087db7ecf65aca92107a.tar.gz
Merge "Eventlet green threads not released back to pool" into stable/juno
-rw-r--r--doc/source/configuring.rst11
-rw-r--r--etc/glance-api.conf7
-rw-r--r--etc/glance-registry.conf7
-rw-r--r--glance/common/wsgi.py9
-rw-r--r--glance/tests/unit/common/test_wsgi.py22
-rw-r--r--glance/tests/unit/test_opts.py6
6 files changed, 58 insertions, 4 deletions
diff --git a/doc/source/configuring.rst b/doc/source/configuring.rst
index 17a7ae4c5..5fd984009 100644
--- a/doc/source/configuring.rst
+++ b/doc/source/configuring.rst
@@ -1331,3 +1331,14 @@ glance-registry service separately, by default they place at
to make profiling work as designed operator needs to make those values of HMAC
key be consistent for all services in your deployment. Without HMAC key the
profiling will not be triggered even profiling feature is enabled.
+
+Configuring http_keepalive option
+----------------------------------
+
+* ``http_keepalive=<True|False>``
+
+If False, server will return the header "Connection: close", If True, server
+will return "Connection: Keep-Alive" in its responses. 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 this option to False when
+you create a wsgi server.
diff --git a/etc/glance-api.conf b/etc/glance-api.conf
index cfc214e91..3867ad796 100644
--- a/etc/glance-api.conf
+++ b/etc/glance-api.conf
@@ -109,6 +109,13 @@ backlog = 4096
# and 'store_type'.
#location_strategy = location_order
+# http_keepalive option. If False, server will return the header
+# "Connection: close", If True, server will return "Connection: Keep-Alive"
+# in its responses. 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 this option to False when you create a wsgi server.
+#http_keepalive = True
+
# ================= Syslog Options ============================
# Send logs to syslog (/dev/log) instead of to file specified
diff --git a/etc/glance-registry.conf b/etc/glance-registry.conf
index a72abf8ca..0470a8bc1 100644
--- a/etc/glance-registry.conf
+++ b/etc/glance-registry.conf
@@ -58,6 +58,13 @@ limit_param_default = 25
# Default: False
#sqlalchemy_debug = True
+# http_keepalive option. If False, server will return the header
+# "Connection: close", If True, server will return "Connection: Keep-Alive"
+# in its responses. 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 this option to False when you create a wsgi server.
+#http_keepalive = True
+
# ================= Syslog Options ============================
# Send logs to syslog (/dev/log) instead of to file specified
diff --git a/glance/common/wsgi.py b/glance/common/wsgi.py
index afcf2e05b..da76e259c 100644
--- a/glance/common/wsgi.py
+++ b/glance/common/wsgi.py
@@ -89,6 +89,9 @@ eventlet_opts = [
'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.BoolOpt('http_keepalive', default=True,
+ help=_('If False, closes the client socket connection '
+ 'explicitly.')),
]
profiler_opts = [
@@ -340,7 +343,8 @@ class Server(object):
self.application,
log=logging.WritableLogger(self.logger),
custom_pool=self.pool,
- debug=False)
+ debug=False,
+ keepalive=CONF.http_keepalive)
except socket.error as err:
if err[0] != errno.EINVAL:
raise
@@ -351,7 +355,8 @@ class Server(object):
self.logger.info(_("Starting single process server"))
eventlet.wsgi.server(sock, application, custom_pool=self.pool,
log=logging.WritableLogger(self.logger),
- debug=False)
+ debug=False,
+ keepalive=CONF.http_keepalive)
class Middleware(object):
diff --git a/glance/tests/unit/common/test_wsgi.py b/glance/tests/unit/common/test_wsgi.py
index 56873ab52..065848d5d 100644
--- a/glance/tests/unit/common/test_wsgi.py
+++ b/glance/tests/unit/common/test_wsgi.py
@@ -466,6 +466,28 @@ class ServerTest(test_utils.BaseTestCase):
actual = wsgi.Server(threads=1).create_pool()
self.assertIsInstance(actual, eventlet.greenpool.GreenPool)
+ @mock.patch.object(wsgi, 'get_socket')
+ def test_http_keepalive(self, mock_get_socket):
+ fake_socket = 'fake_socket'
+ mock_get_socket.return_value = 'fake_socket'
+ self.config(http_keepalive=False)
+ self.config(workers=0)
+
+ server = wsgi.Server(threads=1)
+ # mocking eventlet.wsgi server method to check it is called with
+ # configured 'http_keepalive' value.
+ with mock.patch.object(eventlet.wsgi,
+ 'server') as mock_server:
+ fake_application = "fake-application"
+ server.start(fake_application, 0)
+ server.wait()
+ mock_server.assert_called_once_with(fake_socket,
+ fake_application,
+ log=mock.ANY,
+ debug=False,
+ custom_pool=server.pool,
+ keepalive=False)
+
class TestHelpers(test_utils.BaseTestCase):
diff --git a/glance/tests/unit/test_opts.py b/glance/tests/unit/test_opts.py
index fbe46aac3..a55a2287c 100644
--- a/glance/tests/unit/test_opts.py
+++ b/glance/tests/unit/test_opts.py
@@ -145,7 +145,8 @@ class OptsTestCase(utils.BaseTestCase):
'eventlet_executor_pool_size',
'store_type_preference',
'flavor',
- 'config_file'
+ 'config_file',
+ 'http_keepalive',
]
self._check_opt_groups(opt_list, expected_opt_groups)
@@ -205,7 +206,8 @@ class OptsTestCase(utils.BaseTestCase):
'eventlet_hub',
'max_header_line',
'flavor',
- 'config_file'
+ 'config_file',
+ 'http_keepalive',
]
self._check_opt_groups(opt_list, expected_opt_groups)