]> 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)
committerThomas Goirand <thomas@goirand.fr>
Sun, 14 Dec 2014 09:18:31 +0000 (09:18 +0000)
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
(cherry picked from commit 6c3ad4cf55c5f4cb610fb2625aed1286857b6c67)

cinder/tests/test_wsgi.py
cinder/wsgi.py

index a267bb879e4affbf10e0157296f042919afc74e2..1324264a7a258df4a1f6d42bc204f37a39036834 100644 (file)
@@ -124,6 +124,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 cbd62e665554e74250149e0edee3485160858e03..77ddba6d59773f800e38563d82f8ca762fccd11b 100644 (file)
@@ -267,6 +267,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."))