[node-patches] Change in ovirt-node[master]: ovirt-node-upgrade: add lock file check to prevent parallel ...

jboggs at redhat.com jboggs at redhat.com
Tue May 21 18:37:55 UTC 2013


Joey Boggs has uploaded a new change for review.

Change subject: ovirt-node-upgrade: add lock file check to prevent parallel runs
......................................................................

ovirt-node-upgrade: add lock file check to prevent parallel runs

Change-Id: Ifdd6553046d99cf9c9db29c1c899dc93e8ad733a
Signed-off-by: Joey Boggs <jboggs at redhat.com>
---
M scripts/ovirt-node-upgrade.py
1 file changed, 9 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/60/14960/1

diff --git a/scripts/ovirt-node-upgrade.py b/scripts/ovirt-node-upgrade.py
index 8fcc372..81f1df8 100755
--- a/scripts/ovirt-node-upgrade.py
+++ b/scripts/ovirt-node-upgrade.py
@@ -64,6 +64,13 @@
     console.setFormatter(conformatter)
     logger.addHandler(console)
 
+def lockFileCheck():
+    locks = []
+    for f in os.listdir("/tmp"):
+        if f.startswith('.ovirtupgrade'):
+            locks.append(f)
+    if len(locks) > 0:
+        raise RuntimeError("Existing Lockfile Detected: %s" % locks)
 
 class Base(object):
     def __init__(self):
@@ -203,9 +210,9 @@
     def _cleanup(self):
         self._logger.info("Cleaning up temporary directory")
         try:
+            os.remove(self._lock_file)
             for dir in [self._chroot_path, self._squashfs_dir, "/live"]:
                 self._system(which("umount"), dir)
-            os.remove(self._lock_file)
             shutil.rmtree(self._tmp_dir)
         except:
             self._logger.warning("Cleanup Failed")
@@ -309,5 +316,6 @@
 
 if __name__ == "__main__":
     initLogger()
+    lockFileCheck()
     u = UpgradeTool()
     u.run()


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifdd6553046d99cf9c9db29c1c899dc93e8ad733a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Joey Boggs <jboggs at redhat.com>



More information about the node-patches mailing list