From 6c3ad4cf55c5f4cb610fb2625aed1286857b6c67 Mon Sep 17 00:00:00 2001 From: Zhiteng Huang Date: Tue, 21 Oct 2014 17:05:50 +0800 Subject: [PATCH] Cinder api service doesn't handle SIGHUP properly When SIGHUP signal is sent to cinder-api service, it doesn't complete processing of all pending requests before terminating all the processes. This change is a copy of Abhishek Kekane's fix for nova api. Change-Id: I049d2aa2f3ad1fe388e00213a71f374803ed409a Closes-Bug: #1334647 --- cinder/tests/test_wsgi.py | 11 +++++++++++ cinder/wsgi.py | 1 + 2 files changed, 12 insertions(+) diff --git a/cinder/tests/test_wsgi.py b/cinder/tests/test_wsgi.py index 36c1e73b5..721b4bc99 100644 --- a/cinder/tests/test_wsgi.py +++ b/cinder/tests/test_wsgi.py @@ -127,6 +127,17 @@ class TestWSGIServer(test.TestCase): server.stop() server.wait() + def test_server_pool_waitall(self): + # test pools waitall method gets called while stopping server + server = cinder.wsgi.Server("test_server", None, + host="127.0.0.1", port=4444) + server.start() + with mock.patch.object(server._pool, + 'waitall') as mock_waitall: + server.stop() + server.wait() + mock_waitall.assert_called_once_with() + def test_app(self): greetings = 'Hello, World!!!' diff --git a/cinder/wsgi.py b/cinder/wsgi.py index 5e433e723..a7cfbcb49 100644 --- a/cinder/wsgi.py +++ b/cinder/wsgi.py @@ -274,6 +274,7 @@ class Server(object): """ try: if self._server is not None: + self._pool.waitall() self._server.wait() except greenlet.GreenletExit: LOG.info(_("WSGI server has stopped.")) -- 2.45.2