From 918ab8543ecf93c98e1cb49640b68e7a181f9a50 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Wed, 11 Nov 2020 14:18:13 -0800 Subject: [PATCH] Use socket_timeout kwarg instead of useless eventlet.wsgi.WRITE_TIMEOUT No version of eventlet that I'm aware of hasany sort of support for eventlet.wsgi.WRITE_TIMEOUT; I don't know why we've been setting that. On the other hand, the socket_timeout argument for eventlet.wsgi.Server has been supported for a while -- since 0.14 in 2013. Drive-by: Fix up handling of sub-second client_timeouts. Change-Id: I1dca3c3a51a83c9d5212ee5a0ad2ba1343c68cf9 Related-Change: I1d4d028ac5e864084a9b7537b140229cb235c7a3 Related-Change: I433c97df99193ec31c863038b9b6fd20bb3705b8 --- etc/object-server.conf-sample | 2 +- etc/proxy-server.conf-sample | 2 +- swift/common/wsgi.py | 3 +-- swift/obj/server.py | 2 +- test/functional/__init__.py | 3 --- test/unit/common/test_wsgi.py | 12 ++++++------ 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/etc/object-server.conf-sample b/etc/object-server.conf-sample index 06f10c846c..b4ae1c25ea 100644 --- a/etc/object-server.conf-sample +++ b/etc/object-server.conf-sample @@ -76,7 +76,7 @@ bind_port = 6200 # container_update_timeout = 1.0 # Time to wait while receiving each chunk of data from a client or another # backend node. -# client_timeout = 60 +# client_timeout = 60.0 # # network_chunk_size = 65536 # disk_chunk_size = 65536 diff --git a/etc/proxy-server.conf-sample b/etc/proxy-server.conf-sample index 4d8c5792de..3b3795c011 100644 --- a/etc/proxy-server.conf-sample +++ b/etc/proxy-server.conf-sample @@ -85,7 +85,7 @@ bind_port = 8080 # CORS documentation). # cors_expose_headers = # -# client_timeout = 60 +# client_timeout = 60.0 # eventlet_debug = false # # You can set scheduling priority of processes. Niceness values range from -20 diff --git a/swift/common/wsgi.py b/swift/common/wsgi.py index 0fe28377f6..46377d02ed 100644 --- a/swift/common/wsgi.py +++ b/swift/common/wsgi.py @@ -642,8 +642,6 @@ def run_server(conf, logger, sock, global_conf=None, ready_callback=None): os.environ['TZ'] = 'UTC+0' time.tzset() - wsgi.WRITE_TIMEOUT = int(conf.get('client_timeout') or 60) - eventlet.hubs.use_hub(get_hub()) eventlet_debug = config_true_value(conf.get('eventlet_debug', 'no')) eventlet.debug.hub_exceptions(eventlet_debug) @@ -672,6 +670,7 @@ def run_server(conf, logger, sock, global_conf=None, ready_callback=None): server_kwargs = { 'custom_pool': pool, 'protocol': protocol_class, + 'socket_timeout': float(conf.get('client_timeout') or 60), # Disable capitalizing headers in Eventlet. This is necessary for # the AWS SDK to work with s3api middleware (it needs an "ETag" # header; "Etag" just won't do). diff --git a/swift/obj/server.py b/swift/obj/server.py index 5a883e4c1d..1e0c95da62 100644 --- a/swift/obj/server.py +++ b/swift/obj/server.py @@ -145,7 +145,7 @@ class ObjectController(BaseStorageServer): self.container_update_timeout = float( conf.get('container_update_timeout', 1)) self.conn_timeout = float(conf.get('conn_timeout', 0.5)) - self.client_timeout = int(conf.get('client_timeout', 60)) + self.client_timeout = float(conf.get('client_timeout', 60)) self.disk_chunk_size = int(conf.get('disk_chunk_size', 65536)) self.network_chunk_size = int(conf.get('network_chunk_size', 65536)) self.log_requests = config_true_value(conf.get('log_requests', 'true')) diff --git a/test/functional/__init__.py b/test/functional/__init__.py index 5bfe7f9762..4c25683bb3 100644 --- a/test/functional/__init__.py +++ b/test/functional/__init__.py @@ -647,9 +647,6 @@ def in_process_setup(the_object_server=object_server): 'port': con2lis.getsockname()[1]}], 30), f) - # Default to only 4 seconds for in-process functional test runs - eventlet.wsgi.WRITE_TIMEOUT = 4 - def get_logger_name(name): if show_debug_logs: return debug_logger(name) diff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py index 0d783f25f0..6b0f51fed9 100644 --- a/test/unit/common/test_wsgi.py +++ b/test/unit/common/test_wsgi.py @@ -467,7 +467,6 @@ class TestWSGI(unittest.TestCase): logger = logging.getLogger('test') sock = listen_zero() wsgi.run_server(conf, logger, sock) - self.assertEqual(30, _wsgi.WRITE_TIMEOUT) _wsgi_evt.hubs.use_hub.assert_called_with(utils.get_hub()) _wsgi_evt.debug.hub_exceptions.assert_called_with(False) self.assertTrue(_wsgi.server.called) @@ -479,6 +478,7 @@ class TestWSGI(unittest.TestCase): self.assertTrue(isinstance(server_logger, wsgi.NullLogger)) self.assertTrue('custom_pool' in kwargs) self.assertEqual(1000, kwargs['custom_pool'].size) + self.assertEqual(30, kwargs['socket_timeout']) proto_class = kwargs['protocol'] self.assertEqual(proto_class, wsgi.SwiftHttpProtocol) @@ -497,7 +497,7 @@ class TestWSGI(unittest.TestCase): [app:proxy-server] use = egg:swift#proxy # these "set" values override defaults - set client_timeout = 20 + set client_timeout = 2.5 set max_clients = 10 require_proxy_protocol = true """ @@ -517,7 +517,6 @@ class TestWSGI(unittest.TestCase): logger = logging.getLogger('test') sock = listen_zero() wsgi.run_server(conf, logger, sock) - self.assertEqual(20, _wsgi.WRITE_TIMEOUT) _eventlet.hubs.use_hub.assert_called_with(utils.get_hub()) _eventlet.debug.hub_exceptions.assert_called_with(False) self.assertTrue(_wsgi.server.called) @@ -525,10 +524,11 @@ class TestWSGI(unittest.TestCase): server_sock, server_app, server_logger = args self.assertEqual(sock, server_sock) self.assertTrue(isinstance(server_app, swift.proxy.server.Application)) - self.assertEqual(20, server_app.client_timeout) + self.assertEqual(2.5, server_app.client_timeout) self.assertTrue(isinstance(server_logger, wsgi.NullLogger)) self.assertTrue('custom_pool' in kwargs) self.assertEqual(10, kwargs['custom_pool'].size) + self.assertEqual(2.5, kwargs['socket_timeout']) proto_class = kwargs['protocol'] self.assertEqual(proto_class, wsgi.SwiftHttpProxiedProtocol) @@ -602,7 +602,6 @@ class TestWSGI(unittest.TestCase): wsgi.run_server(conf, logger, sock) self.assertNotEqual(os.environ['TZ'], '') - self.assertEqual(30, _wsgi.WRITE_TIMEOUT) _wsgi_evt.hubs.use_hub.assert_called_with(utils.get_hub()) _wsgi_evt.debug.hub_exceptions.assert_called_with(False) self.assertTrue(_wsgi.server.called) @@ -612,6 +611,7 @@ class TestWSGI(unittest.TestCase): self.assertTrue(isinstance(server_app, swift.proxy.server.Application)) self.assertTrue(isinstance(server_logger, wsgi.NullLogger)) self.assertTrue('custom_pool' in kwargs) + self.assertEqual(30, kwargs['socket_timeout']) self.assertTrue('protocol' in kwargs) self.assertEqual('HTTP/1.0', kwargs['protocol'].default_request_version) @@ -652,7 +652,6 @@ class TestWSGI(unittest.TestCase): logger = logging.getLogger('test') sock = listen_zero() wsgi.run_server(conf, logger, sock) - self.assertEqual(30, _wsgi.WRITE_TIMEOUT) _wsgi_evt.hubs.use_hub.assert_called_with(utils.get_hub()) _wsgi_evt.debug.hub_exceptions.assert_called_with(True) self.assertTrue(mock_server.called) @@ -664,6 +663,7 @@ class TestWSGI(unittest.TestCase): self.assertIsNone(server_logger) self.assertTrue('custom_pool' in kwargs) self.assertEqual(1000, kwargs['custom_pool'].size) + self.assertEqual(30, kwargs['socket_timeout']) self.assertTrue('protocol' in kwargs) self.assertEqual('HTTP/1.0', kwargs['protocol'].default_request_version)