]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Graceful shutdown WSGI/RPC server
authorMitsuhiro Tanino <mitsuhiro.tanino@hds.com>
Wed, 24 Jun 2015 03:49:50 +0000 (23:49 -0400)
committerMitsuhiro Tanino <mitsuhiro.tanino@hds.com>
Fri, 17 Jul 2015 18:55:22 +0000 (18:55 +0000)
Change-ID I80487f559302b0e88953835ffb4a3bfe2a347501 introduces
oslo.service into Cinder. The graceful shutdown of RPC server
was introduced via merging of oslo.service.
Actual fix was introduced by https://review.openstack.org/#/c/190175/
into oslo.service.

The oslo.service fix provides this facility through it's wait()
method, so we need to call it in Cinder Service wait() method
which gets called when graceful shutdown is requested by sending
the process SIGTERM.

Change-Id: Iea877e062272103ea48583b5638dec6174e99de0
Closes-Bug: 1464822

cinder/service.py
cinder/tests/unit/test_service.py

index b41f135d363e9ab02c1624bcf72ef19659df9226..595e6da4ceecf2659f4b7e79db70501ed3072258 100644 (file)
@@ -135,6 +135,7 @@ class Service(service.Service):
         self.timers = []
 
         setup_profiler(binary, host)
+        self.rpcserver = None
 
     def start(self):
         version_string = version.version_string()
@@ -263,7 +264,6 @@ class Service(service.Service):
         # errors, go ahead and ignore them.. as we're shutting down anyway
         try:
             self.rpcserver.stop()
-            self.rpcserver.wait()
         except Exception:
             pass
         for x in self.timers:
@@ -280,6 +280,8 @@ class Service(service.Service):
                 x.wait()
             except Exception:
                 pass
+        if self.rpcserver:
+            self.rpcserver.wait()
 
     def periodic_tasks(self, raise_on_error=False):
         """Tasks to be run at a periodic interval."""
index 5c95ed0593fa06d7af6309e8376cacd9ea582585..c70cbc484e6b67aa263037eb4cac45d75afac5ab 100644 (file)
@@ -240,6 +240,7 @@ class ServiceTestCase(test.TestCase):
         )
         serv.start()
         serv.stop()
+        serv.wait()
         serv.rpcserver.start.assert_called_once_with()
         serv.rpcserver.stop.assert_called_once_with()
         serv.rpcserver.wait.assert_called_once_with()