d1681e
From 8c9028b560b1f0fd816e7d2a9e0bec70cc526c1a Mon Sep 17 00:00:00 2001
d1681e
From: Kotresh HR <khiremat@redhat.com>
d1681e
Date: Sat, 7 Jul 2018 08:58:08 -0400
d1681e
Subject: [PATCH 317/325] geo-rep/scheduler: Fix EBUSY trace back
d1681e
d1681e
Fix the trace back during temporary mount
d1681e
cleanup. Temporary mount is done to touch
d1681e
the root required for checkpoint to complete.
d1681e
d1681e
Backport of
d1681e
 > Patch: https://review.gluster.org/#/c/20476/
d1681e
 > BUG: 1598977
d1681e
 > Change-Id: I97fea538e92c4ef0747747e981ef98499504e336
d1681e
 > Signed-off-by: Kotresh HR <khiremat@redhat.com>
d1681e
d1681e
BUG: 1568896
d1681e
Change-Id: I97fea538e92c4ef0747747e981ef98499504e336
d1681e
Signed-off-by: Kotresh HR <khiremat@redhat.com>
d1681e
Reviewed-on: https://code.engineering.redhat.com/gerrit/143949
d1681e
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d1681e
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d1681e
---
d1681e
 extras/geo-rep/schedule_georep.py.in | 25 ++++++++++++++++++++-----
d1681e
 1 file changed, 20 insertions(+), 5 deletions(-)
d1681e
d1681e
diff --git a/extras/geo-rep/schedule_georep.py.in b/extras/geo-rep/schedule_georep.py.in
d1681e
index 4e1a071..3797fff 100644
d1681e
--- a/extras/geo-rep/schedule_georep.py.in
d1681e
+++ b/extras/geo-rep/schedule_georep.py.in
d1681e
@@ -43,7 +43,7 @@ SESSION_MOUNT_LOG_FILE = ("/var/log/glusterfs/geo-replication"
d1681e
                           "/schedule_georep.mount.log")
d1681e
 
d1681e
 USE_CLI_COLOR = True
d1681e
-
d1681e
+mnt_list = []
d1681e
 
d1681e
 class GlusterBadXmlFormat(Exception):
d1681e
     """
d1681e
@@ -90,6 +90,8 @@ def execute(cmd, success_msg="", failure_msg="", exitcode=-1):
d1681e
             output_ok(success_msg)
d1681e
         return out
d1681e
     else:
d1681e
+        if exitcode == 0:
d1681e
+            return
d1681e
         err_msg = err if err else out
d1681e
         output_notok(failure_msg, err=err_msg, exitcode=exitcode)
d1681e
 
d1681e
@@ -112,12 +114,12 @@ def cleanup(hostname, volname, mnt):
d1681e
     """
d1681e
     Unmount the Volume and Remove the temporary directory
d1681e
     """
d1681e
-    execute(["umount", mnt],
d1681e
+    execute(["umount", "-l", mnt],
d1681e
             failure_msg="Unable to Unmount Gluster Volume "
d1681e
             "{0}:{1}(Mounted at {2})".format(hostname, volname, mnt))
d1681e
     execute(["rmdir", mnt],
d1681e
             failure_msg="Unable to Remove temp directory "
d1681e
-            "{0}".format(mnt))
d1681e
+            "{0}".format(mnt), exitcode=0)
d1681e
 
d1681e
 
d1681e
 @contextmanager
d1681e
@@ -130,6 +132,7 @@ def glustermount(hostname, volname):
d1681e
     Automatically unmounts it in case of Exceptions/out of context
d1681e
     """
d1681e
     mnt = tempfile.mkdtemp(prefix="georepsetup_")
d1681e
+    mnt_list.append(mnt)
d1681e
     execute(["@SBIN_DIR@/glusterfs",
d1681e
              "--volfile-server", hostname,
d1681e
              "--volfile-id", volname,
d1681e
@@ -378,14 +381,14 @@ def main(args):
d1681e
     output_ok("Started Geo-replication and watching Status for "
d1681e
               "Checkpoint completion")
d1681e
 
d1681e
-    touch_mount_root(args.mastervol)
d1681e
-
d1681e
     start_time = int(time.time())
d1681e
     duration = 0
d1681e
 
d1681e
     # Sleep till Geo-rep initializes
d1681e
     time.sleep(60)
d1681e
 
d1681e
+    touch_mount_root(args.mastervol)
d1681e
+
d1681e
     slave_url = "{0}::{1}".format(args.slave, args.slavevol)
d1681e
 
d1681e
     # Loop to Check the Geo-replication Status and Checkpoint
d1681e
@@ -446,6 +449,11 @@ def main(args):
d1681e
 
d1681e
         time.sleep(args.interval)
d1681e
 
d1681e
+    for mnt in mnt_list:
d1681e
+        execute(["rmdir", mnt],
d1681e
+                failure_msg="Unable to Remove temp directory "
d1681e
+                "{0}".format(mnt), exitcode=0)
d1681e
+
d1681e
 if __name__ == "__main__":
d1681e
     parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter,
d1681e
                             description=__doc__)
d1681e
@@ -474,4 +482,11 @@ if __name__ == "__main__":
d1681e
         execute(cmd)
d1681e
         main(args)
d1681e
     except KeyboardInterrupt:
d1681e
+        for mnt in mnt_list:
d1681e
+            execute(["umount", "-l", mnt],
d1681e
+                    failure_msg="Unable to Unmount Gluster Volume "
d1681e
+                    "Mounted at {0}".format(mnt), exitcode=0)
d1681e
+            execute(["rmdir", mnt],
d1681e
+                    failure_msg="Unable to Remove temp directory "
d1681e
+                    "{0}".format(mnt), exitcode=0)
d1681e
         output_notok("Exiting...")
d1681e
-- 
d1681e
1.8.3.1
d1681e