Change in vdsm[master]: svdsm: Remove superfluous unlinks

smizrahi at redhat.com smizrahi at redhat.com
Tue Feb 12 18:32:39 UTC 2013


Saggi Mizrahi has uploaded a new change for review.

Change subject: svdsm: Remove superfluous unlinks
......................................................................

svdsm: Remove superfluous unlinks

This causes races and is generally unnecessary

Bug-Id: https://bugzilla.redhat.com/910005
Change-Id: I6c3e1968666a34fdfc4b9df8d8c320bcc82c47ca
Signed-off-by: Saggi Mizrahi <smizrahi at redhat.com>
---
M vdsm/supervdsm.py
M vdsm/supervdsmServer.py
2 files changed, 48 insertions(+), 49 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/89/11989/1

diff --git a/vdsm/supervdsm.py b/vdsm/supervdsm.py
index 10abae0..127dd78 100644
--- a/vdsm/supervdsm.py
+++ b/vdsm/supervdsm.py
@@ -112,10 +112,10 @@
         return self._manager.open(*args, **kwargs)
 
     def _cleanOldFiles(self):
-        self._log.debug("Cleanning svdsm old files: %s, %s, %s",
+        self._log.debug("Cleanning svdsm old files: %s, %s",
                         self.pidfile, self.timestamp, self.address)
-        for f in (self.pidfile, self.timestamp, self.address):
-            utils.rmFile(f)
+        for f in (self.pidfile, self.timestamps):
+            utils.rmFile(str(f))
 
     def _start(self):
         self._authkey = str(uuid.uuid4())
@@ -194,7 +194,7 @@
     def launch(self):
         self._firstLaunch = False
         self._start()
-        utils.retry(self._connect, Exception, timeout=60)
+        utils.retry(self._connect, Exception, timeout=1)
 
     def __getattr__(self, name):
         return ProxyCaller(self, name)
diff --git a/vdsm/supervdsmServer.py b/vdsm/supervdsmServer.py
index 83a5803..21cf579 100755
--- a/vdsm/supervdsmServer.py
+++ b/vdsm/supervdsmServer.py
@@ -366,57 +366,56 @@
 
     log = logging.getLogger("SuperVdsm.Server")
 
+    log.debug("Making sure I'm root")
+    if os.geteuid() != 0:
+        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"))
+
+    log.debug("Cleaning old socket %s", address)
+    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("Making sure I'm root")
-        if os.geteuid() != 0:
-            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"))
-
-        log.debug("Cleaning old socket %s", address)
-        if os.path.exists(address):
-            os.unlink(address)
-
-        zombieReaper.registerSignalHandler()
-
-        log.debug("Setting up keep alive thread")
-
-        monThread = threading.Thread(target=__pokeParent,
-                                     args=[int(parentPid), address, log])
-        monThread.setDaemon(True)
-        monThread.start()
-
+        log.debug("Creating remote object manager")
         try:
-            log.debug("Creating remote object manager")
-            manager = _SuperVdsmManager(address=address, authkey=authkey)
-            manager.register('instance', callable=_SuperVdsm)
+            os.unlink(address)
+        except (OSError, IOError) as e:
+            if e.errno != errno.ENOENT:
+                raise
 
-            server = manager.get_server()
-            servThread = threading.Thread(target=server.serve_forever)
-            servThread.setDaemon(True)
-            servThread.start()
+        manager = _SuperVdsmManager(address=address, authkey=authkey)
+        manager.register('instance', callable=_SuperVdsm)
 
-            for f in (address, timestamp, pidfile):
-                chown(f, int(uid), METADATA_GROUP)
+        server = manager.get_server()
+        servThread = threading.Thread(target=server.serve_forever)
+        servThread.setDaemon(True)
+        servThread.start()
 
-            log.debug("Started serving super vdsm object")
+        for f in (address, timestamp, pidfile):
+            chown(f, int(uid), METADATA_GROUP)
 
-            # Python bug of thread.join() will block signal
-            # http://bugs.python.org/issue1167930
-            while servThread.isAlive():
-                servThread.join(5)
-        finally:
-            if os.path.exists(address):
-                utils.rmFile(address)
+        log.debug("Started serving super vdsm object")
+
+        # Python bug of thread.join() will block signal
+        # http://bugs.python.org/issue1167930
+        while servThread.isAlive():
+            servThread.join(5)
 
     except Exception:
         log.error("Could not start Super Vdsm", exc_info=True)


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c3e1968666a34fdfc4b9df8d8c320bcc82c47ca
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi at redhat.com>


More information about the vdsm-patches mailing list