coren has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/226892

Change subject: Make sure storage-replicate only removes the lockdir if it held 
the lock
......................................................................

Make sure storage-replicate only removes the lockdir if it held the lock

To avoid an aborted attempt cleaning up when it shouldn't.

Change-Id: Id5b8a8a9ef1a1150b5b84394d2392a4464328117
---
M modules/labstore/files/storage-replicate
1 file changed, 5 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/92/226892/1

diff --git a/modules/labstore/files/storage-replicate 
b/modules/labstore/files/storage-replicate
index 617c4a2..e6d1313 100755
--- a/modules/labstore/files/storage-replicate
+++ b/modules/labstore/files/storage-replicate
@@ -139,18 +139,21 @@
         self.path = path
         self.mountpoint = "%s/snapshot" % path
         self.err = None
+        self.locked = False
 
     def __enter__(self):
         try:
             os.mkdir(self.path, 0o700)
             os.mkdir(self.mountpoint, 0o700)
+            self.locked = True
         except OSError as e:
             self.err = "unable to create lock directory %s: %s" % (self.path, 
e.strerror)
         return self
 
     def __exit__(self, e1, e2, e3):
-        (out, err) = self.ctx.run('/bin/umount', '-fl', self.mountpoint)
-        (out, err) = self.ctx.run('/bin/rm', '-rf', self.path)
+        if self.locked:
+            (out, err) = self.ctx.run('/bin/umount', '-fl', self.mountpoint)
+            (out, err) = self.ctx.run('/bin/rm', '-rf', self.path)
         return None
 
 

-- 
To view, visit https://gerrit.wikimedia.org/r/226892
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id5b8a8a9ef1a1150b5b84394d2392a4464328117
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: coren <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to