12a457
From ca5477127e48f6a597098045d70cb525d79648ae Mon Sep 17 00:00:00 2001
12a457
From: Aravinda VK <avishwan@redhat.com>
12a457
Date: Fri, 29 Apr 2016 13:03:40 +0530
12a457
Subject: [PATCH 104/104] geo-rep: Fix gluster binary invocation while running as cron
12a457
12a457
When scheduler script was executed as cron, it was unable to detect
12a457
the Gluster binaries.
12a457
12a457
BUG: 1331376
12a457
Change-Id: Ic9c533586ed9a472765f69aa2f87d004c46d4340
12a457
Signed-off-by: Aravinda VK <avishwan@redhat.com>
12a457
Reviewed-on: http://review.gluster.org/14111
12a457
Reviewed-on: http://review.gluster.org/14122
12a457
Reviewed-on: https://code.engineering.redhat.com/gerrit/73379
12a457
---
12a457
 .gitignore                                         |    1 +
12a457
 configure.ac                                       |   17 +++++++++++++++++
12a457
 extras/geo-rep/Makefile.am                         |    4 +++-
12a457
 .../{schedule_georep.py => schedule_georep.py.in}  |   18 ++++++++++--------
12a457
 4 files changed, 31 insertions(+), 9 deletions(-)
12a457
 rename extras/geo-rep/{schedule_georep.py => schedule_georep.py.in} (96%)
12a457
12a457
diff --git a/configure.ac b/configure.ac
12a457
index ff746ff..a6ad6b1 100644
12a457
--- a/configure.ac
12a457
+++ b/configure.ac
12a457
@@ -211,6 +211,7 @@ AC_CONFIG_FILES([Makefile
12a457
                 extras/ocf/volume
12a457
                 extras/LinuxRPM/Makefile
12a457
                 extras/geo-rep/Makefile
12a457
+                extras/geo-rep/schedule_georep.py
12a457
                 extras/firewalld/Makefile
12a457
                 extras/hook-scripts/add-brick/Makefile
12a457
                 extras/hook-scripts/add-brick/pre/Makefile
12a457
@@ -1090,6 +1091,22 @@ case $host_os in
12a457
         ;;
12a457
 esac
12a457
 
12a457
+# Default value for sbindir
12a457
+prefix_temp=$prefix
12a457
+exec_prefix_temp=$exec_prefix
12a457
+
12a457
+test "${prefix}" = "NONE" && prefix="${ac_default_prefix}"
12a457
+test "${exec_prefix}" = "NONE" && exec_prefix='${prefix}'
12a457
+sbintemp="${sbindir}"
12a457
+eval sbintemp=\"${sbintemp}\"
12a457
+eval sbintemp=\"${sbintemp}\"
12a457
+SBIN_DIR=${sbintemp}
12a457
+
12a457
+prefix=$prefix_temp
12a457
+exec_prefix=$exec_prefix_temp
12a457
+
12a457
+AC_SUBST(SBIN_DIR)
12a457
+
12a457
 # lazy umount emulation
12a457
 UMOUNTD_SUBDIR=""
12a457
 if test "x${GF_HOST_OS}" != "xGF_LINUX_HOST_OS" ; then
12a457
diff --git a/extras/geo-rep/Makefile.am b/extras/geo-rep/Makefile.am
12a457
index dcf0fc8..6c334b0 100644
12a457
--- a/extras/geo-rep/Makefile.am
12a457
+++ b/extras/geo-rep/Makefile.am
12a457
@@ -10,4 +10,6 @@ gsync_sync_gfid_SOURCES = gsync-sync-gfid.c
12a457
 gsync_sync_gfid_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src
12a457
 
12a457
 EXTRA_DIST = gsync-sync-gfid.c gsync-upgrade.sh generate-gfid-file.sh \
12a457
-	get-gfid.sh slave-upgrade.sh schedule_georep.py
12a457
+	get-gfid.sh slave-upgrade.sh schedule_georep.py.in
12a457
+
12a457
+CLEANFILES = schedule_georep.py
12a457
diff --git a/extras/geo-rep/schedule_georep.py b/extras/geo-rep/schedule_georep.py.in
12a457
similarity index 96%
12a457
rename from extras/geo-rep/schedule_georep.py
12a457
rename to extras/geo-rep/schedule_georep.py.in
12a457
index 74fc693..c931111 100644
12a457
--- a/extras/geo-rep/schedule_georep.py
12a457
+++ b/extras/geo-rep/schedule_georep.py.in
12a457
@@ -130,7 +130,7 @@ def glustermount(hostname, volname):
12a457
     Automatically unmounts it in case of Exceptions/out of context
12a457
     """
12a457
     mnt = tempfile.mkdtemp(prefix="georepsetup_")
12a457
-    execute(["glusterfs",
12a457
+    execute(["@SBIN_DIR@/glusterfs",
12a457
              "--volfile-server", hostname,
12a457
              "--volfile-id", volname,
12a457
              "-l", SESSION_MOUNT_LOG_FILE,
12a457
@@ -152,7 +152,7 @@ def get_bricks(volname):
12a457
     parsed.
12a457
     """
12a457
     value = []
12a457
-    cmd = ["gluster", "volume", "info", volname, "--xml"]
12a457
+    cmd = ["@SBIN_DIR@/gluster", "volume", "info", volname, "--xml"]
12a457
     info = execute(cmd)
12a457
     try:
12a457
         tree = etree.fromstring(info)
12a457
@@ -169,7 +169,7 @@ def get_bricks(volname):
12a457
 def get_georep_status(mastervol, slave):
12a457
     session_keys = set()
12a457
     out = {}
12a457
-    cmd = ["gluster", "volume", "geo-replication"]
12a457
+    cmd = ["@SBIN_DIR@/gluster", "volume", "geo-replication"]
12a457
     if mastervol is not None:
12a457
         cmd += [mastervol]
12a457
         if slave:
12a457
@@ -357,20 +357,20 @@ def main(args):
12a457
     turns = 1
12a457
 
12a457
     # Stop Force
12a457
-    cmd = ["gluster", "volume", "geo-replication", args.mastervol,
12a457
+    cmd = ["@SBIN_DIR@/gluster", "volume", "geo-replication", args.mastervol,
12a457
            "%s::%s" % (args.slave, args.slavevol), "stop", "force"]
12a457
     execute(cmd)
12a457
     output_ok("Stopped Geo-replication")
12a457
 
12a457
     # Set Checkpoint to NOW
12a457
-    cmd = ["gluster", "volume", "geo-replication", args.mastervol,
12a457
+    cmd = ["@SBIN_DIR@/gluster", "volume", "geo-replication", args.mastervol,
12a457
            "%s::%s" % (args.slave, args.slavevol), "config", "checkpoint",
12a457
            "now"]
12a457
     execute(cmd)
12a457
     output_ok("Set Checkpoint")
12a457
 
12a457
     # Start the Geo-replication
12a457
-    cmd = ["gluster", "volume", "geo-replication", args.mastervol,
12a457
+    cmd = ["@SBIN_DIR@/gluster", "volume", "geo-replication", args.mastervol,
12a457
            "%s::%s" % (args.slave, args.slavevol), "start"]
12a457
     execute(cmd)
12a457
     output_ok("Started Geo-replication and watching Status for "
12a457
@@ -421,7 +421,8 @@ def main(args):
12a457
 
12a457
         if summary["checkpoints_ok"]:
12a457
             output_ok("Stopping Geo-replication session now")
12a457
-            cmd = ["gluster", "volume", "geo-replication", args.mastervol,
12a457
+            cmd = ["@SBIN_DIR@/gluster", "volume", "geo-replication",
12a457
+                   args.mastervol,
12a457
                    "%s::%s" % (args.slave, args.slavevol), "stop"]
12a457
             execute(cmd)
12a457
             break
12a457
@@ -436,7 +437,8 @@ def main(args):
12a457
         turns += 1
12a457
         duration = int(time.time()) - start_time
12a457
         if args.timeout > 0 and duration > (args.timeout * 60):
12a457
-            cmd = ["gluster", "volume", "geo-replication", args.mastervol,
12a457
+            cmd = ["@SBIN_DIR@/gluster", "volume", "geo-replication",
12a457
+                   args.mastervol,
12a457
                    "%s::%s" % (args.slave, args.slavevol), "stop", "force"]
12a457
             execute(cmd)
12a457
             output_notok("Timed out, Stopping Geo-replication("
12a457
-- 
12a457
1.7.1
12a457