Royce Lv has uploaded a new change for review. Change subject: converge IPC file manipulation function in svdsm ......................................................................
converge IPC file manipulation function in svdsm Change-Id: Ic983da2043f09650fb63e06f4f1ac3d3e218bcc2 Signed-off-by: Royce Lv<[email protected]> --- M tests/superVdsmTests.py M vdsm/supervdsm.py M vdsm/supervdsmServer.py 3 files changed, 21 insertions(+), 20 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/84/10184/1 diff --git a/tests/superVdsmTests.py b/tests/superVdsmTests.py index 87de66d..192c60f 100644 --- a/tests/superVdsmTests.py +++ b/tests/superVdsmTests.py @@ -27,8 +27,8 @@ superVdsmCmd = [getNeededPythonPath(), constants.EXT_PYTHON, supervdsm.SUPERVDSM, - self._authkey, str(os.getpid()), - self.pidfile, self.timestamp, self.address, + self._authkey, str(os.getpid()), self.address, + self.pidfile, self.timestamp, str(os.getuid())] misc.execCmd(superVdsmCmd, sync=False, sudo=True) sleep(2) diff --git a/vdsm/supervdsm.py b/vdsm/supervdsm.py index 532d5ac..2fb3c6a 100644 --- a/vdsm/supervdsm.py +++ b/vdsm/supervdsm.py @@ -121,8 +121,8 @@ # to create its internal files and give to the passed uid the # permissions to read those files. superVdsmCmd = [constants.EXT_PYTHON, SUPERVDSM, - self._authkey, str(os.getpid()), - self.pidfile, self.timestamp, self.address, + self.address, self._authkey, str(os.getpid()), + self.pidfile, self.timestamp, str(os.getuid())] misc.execCmd(superVdsmCmd, sync=False, sudo=True) diff --git a/vdsm/supervdsmServer.py b/vdsm/supervdsmServer.py index 5effd41..24d35ea 100755 --- a/vdsm/supervdsmServer.py +++ b/vdsm/supervdsmServer.py @@ -306,6 +306,20 @@ os.kill(os.getpid(), signal.SIGTERM) +def _prepareIPCFiles(log, ipcPaths): + address, pidfile, timestamp, uid = ipcPaths + log.debug("Creating PID and TIMESTAMP files: %s, %s", + pidfile, timestamp) + spid = os.getpid() + with open(pidfile, "w") as f: + f.write(str(spid) + "\n") + with open(timestamp, "w") as f: + f.write(str(misc.getProcCtime(spid) + "\n")) + + for f in (address, timestamp, pidfile): + chown(f, int(uid), METADATA_GROUP) + + def main(): if _glusterEnabled: def bind(func): @@ -336,19 +350,10 @@ sys.exit(errno.EPERM) log.debug("Parsing cmd args") - authkey, parentPid, pidfile, timestamp, address, uid = sys.argv[1:] - log.debug("Creating PID and TIMESTAMP files: %s, %s", - pidfile, timestamp) - spid = os.getpid() - with open(pidfile, "w") as f: - f.write(str(spid) + "\n") - with open(timestamp, "w") as f: - f.write(str(misc.getProcCtime(spid) + "\n")) - + authkey, parentPid, address = sys.argv[1:4] log.debug("Cleaning old socket %s", address) - if os.path.exists(address): - os.unlink(address) + utils.rmFile(address) zombieReaper.registerSignalHandler() @@ -363,16 +368,12 @@ log.debug("Creating remote object manager") manager = _SuperVdsmManager(address=address, authkey=authkey) manager.register('instance', callable=_SuperVdsm) - server = manager.get_server() servThread = threading.Thread(target=server.serve_forever) servThread.setDaemon(True) servThread.start() - - for f in (address, timestamp, pidfile): - chown(f, int(uid), METADATA_GROUP) - log.debug("Started serving super vdsm object") + _prepareIPCFiles(log, sys.argv[3:7]) # Python bug of thread.join() will block signal # http://bugs.python.org/issue1167930 -- To view, visit http://gerrit.ovirt.org/10184 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic983da2043f09650fb63e06f4f1ac3d3e218bcc2 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Royce Lv <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
