]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Cinder api service doesn't handle SIGHUP properly
authorZhiteng Huang <zhithuang@ebaysf.com>
Tue, 21 Oct 2014 09:05:50 +0000 (17:05 +0800)
committerZhiteng Huang <zhithuang@ebaysf.com>
Wed, 22 Oct 2014 01:33:51 +0000 (09:33 +0800)
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
cinder/wsgi.py

index 36c1e73b55308f2dd8270f2afc00bc981d1f01da..721b4bc99c8434c38001e30f1046bfa7970e752d 100644 (file)
@@ -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!!!'
 
index 5e433e72369d3c502a2161396251ff98f0e3b4cb..a7cfbcb495d64b5cb1edb38121e6559d875e3879 100644 (file)
@@ -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."))