Change in vdsm[ovirt-3.3]: clientIF: Clean up shutdown process

nsoffer at redhat.com nsoffer at redhat.com
Thu Mar 27 14:03:50 UTC 2014


Nir Soffer has uploaded a new change for review.

Change subject: clientIF: Clean up shutdown process
......................................................................

clientIF: Clean up shutdown process

clientIF.serve used to check if shutdown process has started once every
3 seconds, leading to unwanted delay, that may cause vdsm to be killed
before a profile was written.

This patch changes clientIF.serve to start the bindings and return,
allowing the upper layer to wait for a shutdown signal in a more
efficiant way. This allows stopping a profile when shutdown signal is
received, before starting the shutdown process, ensuring that a profile
is written even if shutdown process got stuck and vdsm is killed.

This way is also more safe, as prepareForShutdown is called from the
main thread, instead of the signal handler context, where it is not safe
to call any code. In particular, setting a threading.Event in this
context cause a deadlock.

Change-Id: If7bfa9f7da81ffdfb581299cd14ec4edb50be5fb
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/clientIF.py
M vdsm/vdsm
2 files changed, 10 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/57/26157/1

diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index 47851b1..664011f 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -245,11 +245,9 @@
         finally:
             self._shutdownSemaphore.release()
 
-    def serve(self):
+    def start(self):
         for binding in self.bindings.values():
             binding.start()
-        while self._enabled:
-            time.sleep(3)
 
     def _initIRS(self):
         self.irs = None
diff --git a/vdsm/vdsm b/vdsm/vdsm
index 4fc11c7..aa1bb87 100755
--- a/vdsm/vdsm
+++ b/vdsm/vdsm
@@ -39,11 +39,11 @@
 
 def serve_clients(log):
     cif = None
+    running = [True]
 
     def sigtermHandler(signum, frame):
-        if cif:
-            log.debug("Received signal %s" % signum)
-            cif.prepareForShutdown()
+        log.debug("Received signal %s" % signum)
+        running[0] = False
 
     def sigusr1Handler(signum, frame):
         if cif and cif.irs:
@@ -57,7 +57,12 @@
 
     from clientIF import clientIF  # must import after config is read
     cif = clientIF.getInstance(log)
-    cif.serve()
+    cif.start()
+    try:
+        while running[0]:
+            signal.pause()
+    finally:
+        cif.prepareForShutdown()
 
 
 def run(pidfile=None):


-- 
To view, visit http://gerrit.ovirt.org/26157
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If7bfa9f7da81ffdfb581299cd14ec4edb50be5fb
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.3
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list