Change in vdsm[master]: [WIP]wait vdsm instead of poking it
lvroyce at linux.vnet.ibm.com
lvroyce at linux.vnet.ibm.com
Sun Jan 20 05:23:33 UTC 2013
Royce Lv has uploaded a new change for review.
Change subject: [WIP]wait vdsm instead of poking it
......................................................................
[WIP]wait vdsm instead of poking it
wait vdsm the subprocess, handling signal and error flow
as to terminate the subprocess.
Change-Id: Id2067cbd317cebfb7e0ad5aee64788adef591cf6
Signed-off-by: Royce Lv<lvroyce at linux.vnet.ibm.com>
---
M Makefile.am
M vdsm/supervdsmServer.py
2 files changed, 28 insertions(+), 19 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/92/11192/1
diff --git a/Makefile.am b/Makefile.am
index 48bdc5e..f0876a8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,7 +54,7 @@
vdsm/*.py.in \
vdsm/sos/vdsm.py.in \
vdsm/storage \
- vdsm/vdsm \
+ vdsm/vdsmServer.py \
vdsm_api \
vdsm_cli \
vdsm_hooks \
diff --git a/vdsm/supervdsmServer.py b/vdsm/supervdsmServer.py
index d64076b..77d2798 100755
--- a/vdsm/supervdsmServer.py
+++ b/vdsm/supervdsmServer.py
@@ -32,6 +32,7 @@
from gluster import cli as gcli
import storage.misc as misc
from vdsm import utils
+from vdsmServer import startVdsm
from parted_utils import getDevicePartedInfo as _getDevicePartedInfo
from md_utils import getMdDeviceUuidMap as _getMdDeviceUuidMap
@@ -44,7 +45,7 @@
from storage.fileUtils import chown, resolveGid, resolveUid
from storage.fileUtils import validateAccess as _validateAccess
from vdsm.constants import METADATA_GROUP, EXT_UDEVADM, \
- DISKIMAGE_USER, DISKIMAGE_GROUP, P_LIBVIRT_VMCHANNELS
+ DISKIMAGE_USER, DISKIMAGE_GROUP, P_LIBVIRT_VMCHANNELS, P_VDSM_RUN
from storage.devicemapper import _removeMapping, _getPathsStatus
import configNetwork
from vdsm.config import config
@@ -61,6 +62,7 @@
"%s-%s" + _UDEV_RULE_FILE_EXT
RUN_AS_TIMEOUT = config.getint("irs", "process_pool_timeout")
+ADDRESS = os.path.join(P_VDSM_RUN, "svdsm.sock")
class Timeout(RuntimeError):
@@ -332,18 +334,25 @@
return self.__udevVersion() > self.UDEV_WITH_RELOAD_VERSION
-def __pokeParent(parentPid, address, log):
+def initLogger():
try:
- while True:
- os.kill(parentPid, 0)
- sleep(2)
- except Exception:
- utils.rmFile(address)
- log.debug("Killing SuperVdsm Process")
- os.kill(os.getpid(), signal.SIGTERM)
+ logging.config.fileConfig(LOG_CONF_PATH)
+ except:
+ logging.basicConfig(filename='/dev/stdout', filemode='w+',
+ level=logging.DEBUG)
+ log = logging.getLogger("SuperVdsm.Server")
+ log.warn("Could not init proper logging", exc_info=True)
+
+ log = logging.getLogger("SuperVdsm.Server")
+ return log
-def main():
+def startSvdsm(address, childProc):
+ def sigtermHandler(signum, frame):
+ if childProc.is_alive():
+ childProc.terminate()
+ childProc.join()
+
def bind(func):
def wrapper(_SuperVdsm, *args, **kwargs):
return func(*args, **kwargs)
@@ -365,6 +374,7 @@
log.warn("Could not init proper logging", exc_info=True)
log = logging.getLogger("SuperVdsm.Server")
+ signal.signal(signal.SIGTERM, sigtermHandler)
try:
log.debug("Making sure I'm root")
@@ -388,13 +398,6 @@
zombieReaper.registerSignalHandler()
- log.debug("Setting up keep alive thread")
-
- monThread = threading.Thread(target=__pokeParent,
- args=[int(parentPid), address, log])
- monThread.setDaemon(True)
- monThread.start()
-
try:
log.debug("Creating remote object manager")
manager = _SuperVdsmManager(address=address, authkey=authkey)
@@ -414,11 +417,17 @@
# http://bugs.python.org/issue1167930
while servThread.isAlive():
servThread.join(5)
+ if not childProc.is_alive():
+ childProc.join()
+ raise Exception('Supervdsm died unexpectedly!')
finally:
if os.path.exists(address):
utils.rmFile(address)
except Exception:
+ if childProc.is_alive():
+ childProc.terminate()
+ childProc.join()
log.error("Could not start Super Vdsm", exc_info=True)
sys.exit(1)
@@ -426,4 +435,4 @@
vdsmProc = Process(target=startVdsm)
vdsmProc.start()
sleep(2)
- main()
+ startSvdsm(ADDRESS, vdsmProc)
--
To view, visit http://gerrit.ovirt.org/11192
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id2067cbd317cebfb7e0ad5aee64788adef591cf6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce at linux.vnet.ibm.com>
More information about the vdsm-patches
mailing list