diff options
author | Zuul <zuul@review.opendev.org> | 2023-05-09 02:56:09 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2023-05-09 02:56:09 +0000 |
commit | 89e2050d7f99b8eb392cc35a3d23e4e8eb54fb7a (patch) | |
tree | 150858fb41277d6503cd0502732730f4a658c8ca | |
parent | f99a6e5762896c7789d168bc49d8cdcb47903264 (diff) | |
parent | 469c38e9fb91bf383e92fd697eceb07f30316030 (diff) | |
download | swift-89e2050d7f99b8eb392cc35a3d23e4e8eb54fb7a.tar.gz |
Merge "wsgi: Add keepalive_timeout option"
-rw-r--r-- | etc/proxy-server.conf-sample | 6 | ||||
-rw-r--r-- | swift/common/wsgi.py | 3 | ||||
-rw-r--r-- | test/unit/common/test_wsgi.py | 5 |
3 files changed, 14 insertions, 0 deletions
diff --git a/etc/proxy-server.conf-sample b/etc/proxy-server.conf-sample index d893ff8d7..c47b0cdb2 100644 --- a/etc/proxy-server.conf-sample +++ b/etc/proxy-server.conf-sample @@ -85,8 +85,14 @@ bind_port = 8080 # CORS documentation). # cors_expose_headers = # +# General timeout when sending to or receiving from clients. # client_timeout = 60.0 # +# Timeout to use when looking for pipelined requests. Set to zero to disable +# request pipelining. Defaults to client_timeout. Requires eventlet>=0.33.4; +# with earlier eventlet, any non-zero value is treated as client_timeout. +# keepalive_timeout = +# # Note: enabling evenlet_debug might reveal sensitive information, for example # signatures for temp urls # eventlet_debug = false diff --git a/swift/common/wsgi.py b/swift/common/wsgi.py index 99dc4c203..910d0051c 100644 --- a/swift/common/wsgi.py +++ b/swift/common/wsgi.py @@ -434,6 +434,9 @@ def run_server(conf, logger, sock, global_conf=None, ready_callback=None, # header; "Etag" just won't do). 'capitalize_response_headers': False, } + if conf.get('keepalive_timeout'): + server_kwargs['keepalive'] = float(conf['keepalive_timeout']) or False + if ready_callback: ready_callback() # Yes, eventlet, we know -- we have to support bad clients, though diff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py index a1d9422c8..d2f13b205 100644 --- a/test/unit/common/test_wsgi.py +++ b/test/unit/common/test_wsgi.py @@ -600,6 +600,7 @@ class TestWSGI(unittest.TestCase, ConfigAssertMixin): config = """ [DEFAULT] client_timeout = 30 + keepalive_timeout = 10 max_clients = 1000 swift_dir = TEMPDIR @@ -639,6 +640,7 @@ class TestWSGI(unittest.TestCase, ConfigAssertMixin): self.assertTrue('custom_pool' in kwargs) self.assertEqual(1000, kwargs['custom_pool'].size) self.assertEqual(30, kwargs['socket_timeout']) + self.assertEqual(10, kwargs['keepalive']) proto_class = kwargs['protocol'] self.assertEqual(proto_class, wsgi.SwiftHttpProtocol) @@ -689,6 +691,7 @@ class TestWSGI(unittest.TestCase, ConfigAssertMixin): self.assertTrue('custom_pool' in kwargs) self.assertEqual(10, kwargs['custom_pool'].size) self.assertEqual(2.5, kwargs['socket_timeout']) + self.assertNotIn('keepalive', kwargs) # eventlet defaults to True proto_class = kwargs['protocol'] self.assertEqual(proto_class, wsgi.SwiftHttpProxiedProtocol) @@ -698,6 +701,7 @@ class TestWSGI(unittest.TestCase, ConfigAssertMixin): config = """ [DEFAULT] swift_dir = TEMPDIR + keepalive_timeout = 0 [pipeline:main] pipeline = proxy-server @@ -727,6 +731,7 @@ class TestWSGI(unittest.TestCase, ConfigAssertMixin): self.assertTrue('protocol' in kwargs) self.assertEqual('HTTP/1.0', kwargs['protocol'].default_request_version) + self.assertIs(False, kwargs['keepalive']) def test_run_server_conf_dir(self): config_dir = { |