Change in vdsm[master]: link monitor: do not leave stray `ip monitor` behind

danken at redhat.com danken at redhat.com
Mon Dec 23 16:33:37 UTC 2013


Dan Kenigsberg has uploaded a new change for review.

Change subject: link monitor: do not leave stray `ip monitor` behind
......................................................................

link monitor: do not leave stray `ip monitor` behind

ipwrapper.Monitor.start() spawns an `ip monitor link` process that may
run forever. If Vdsm crashes, we should take care to kill it, or it
would leak.

Due to this patch, ipwrapper.Monitor.start() should be called from an
ever-lasting thread.

Change-Id: Icb1f8998a3f71046c28bf902c851bf900b1e6f7f
Signed-off-by: Dan Kenigsberg <danken at redhat.com>
---
M lib/vdsm/ipwrapper.py
M lib/vdsm/utils.py
2 files changed, 8 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/67/22667/1

diff --git a/lib/vdsm/ipwrapper.py b/lib/vdsm/ipwrapper.py
index 756454b..75f4ad9 100644
--- a/lib/vdsm/ipwrapper.py
+++ b/lib/vdsm/ipwrapper.py
@@ -24,6 +24,7 @@
 import errno
 import fcntl
 import os
+import signal
 import socket
 import struct
 
@@ -609,6 +610,9 @@
         mon.start()
         for event in mon:
             handle event
+
+    Note that the underlying `ip monitor` process is killed when its controlled
+    thread dies, so as not to leave stray processes when Vdsm crahsed.
     """
     _DELETED_TEXT = 'Deleted'
     LINK_STATE_DELETED = 'DELETED'
@@ -624,6 +628,7 @@
 
     def start(self):
         self.proc = execCmd([_IP_BINARY.cmd, '-d', '-o', 'monitor', 'link'],
+                            deathSignal=signal.SIGKILL,
                             sync=False)
         self.proc.blocking = True
 
diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index d593a73..67705db 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -525,7 +525,9 @@
     """
     Executes an external command, optionally via sudo.
 
-    IMPORTANT NOTE: don't define a deathSignal when sync=False
+    IMPORTANT NOTE: the new process would receive `deathSignal` when the
+    controlling thread dies. This is particularly noticeable when using
+    sync=False.
     """
     if ioclass is not None:
         cmd = command


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icb1f8998a3f71046c28bf902c851bf900b1e6f7f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>


More information about the vdsm-patches mailing list