e3c68b
From 1c55f3633f748629cd0484f79b6c49101eb2df82 Mon Sep 17 00:00:00 2001
e3c68b
From: Sunny Kumar <sunkumar@redhat.com>
e3c68b
Date: Mon, 8 Jul 2019 11:47:28 +0530
e3c68b
Subject: [PATCH 226/255] geo-rep : fix gluster command path for non-root
e3c68b
 session
e3c68b
e3c68b
Problem:
e3c68b
gluster command not found.
e3c68b
e3c68b
Cause:
e3c68b
In Volinfo class we issue command 'gluster vol info' to get information
e3c68b
about volume like getting brick_root to perform various operation.
e3c68b
When geo-rep session is configured for non-root user Volinfo class
e3c68b
fails to issue gluster command due to unavailability of gluster
e3c68b
binary path for non-root user.
e3c68b
e3c68b
Solution:
e3c68b
Use config value 'slave-gluster-command-dir'/'gluster-command-dir' to get path
e3c68b
for gluster command based on caller.
e3c68b
e3c68b
>Backport of:
e3c68b
>Upstream Patch: https://review.gluster.org/#/c/glusterfs/+/22920/.
e3c68b
>fixes: bz#1722740
e3c68b
>Change-Id: I4ec46373da01f5d00ecd160c4e8c6239da8b3859
e3c68b
>Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
e3c68b
e3c68b
BUG: 1712591
e3c68b
Change-Id: Ifea2927253a9521fa459fea6de8a60085c3413f6
e3c68b
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
e3c68b
Reviewed-on: https://code.engineering.redhat.com/gerrit/175485
e3c68b
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e3c68b
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
e3c68b
---
e3c68b
 geo-replication/syncdaemon/monitor.py    |  4 ++--
e3c68b
 geo-replication/syncdaemon/syncdutils.py | 12 +++++++++---
e3c68b
 2 files changed, 11 insertions(+), 5 deletions(-)
e3c68b
e3c68b
diff --git a/geo-replication/syncdaemon/monitor.py b/geo-replication/syncdaemon/monitor.py
e3c68b
index c45ef24..234f3f1 100644
e3c68b
--- a/geo-replication/syncdaemon/monitor.py
e3c68b
+++ b/geo-replication/syncdaemon/monitor.py
e3c68b
@@ -369,7 +369,7 @@ def distribute(master, slave):
e3c68b
     if rconf.args.use_gconf_volinfo:
e3c68b
         mvol = VolinfoFromGconf(master.volume, master=True)
e3c68b
     else:
e3c68b
-        mvol = Volinfo(master.volume, master.host)
e3c68b
+        mvol = Volinfo(master.volume, master.host, master=True)
e3c68b
     logging.debug('master bricks: ' + repr(mvol.bricks))
e3c68b
     prelude = []
e3c68b
     slave_host = None
e3c68b
@@ -385,7 +385,7 @@ def distribute(master, slave):
e3c68b
     if rconf.args.use_gconf_volinfo:
e3c68b
         svol = VolinfoFromGconf(slave.volume, master=False)
e3c68b
     else:
e3c68b
-        svol = Volinfo(slave.volume, "localhost", prelude)
e3c68b
+        svol = Volinfo(slave.volume, "localhost", prelude, master=False)
e3c68b
 
e3c68b
     sbricks = svol.bricks
e3c68b
     suuid = svol.uuid
e3c68b
diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py
e3c68b
index 3f41b5f..2ee10ac 100644
e3c68b
--- a/geo-replication/syncdaemon/syncdutils.py
e3c68b
+++ b/geo-replication/syncdaemon/syncdutils.py
e3c68b
@@ -672,7 +672,7 @@ def get_slv_dir_path(slv_host, slv_volume, gfid):
e3c68b
     dir_path = ENOENT
e3c68b
 
e3c68b
     if not slv_bricks:
e3c68b
-        slv_info = Volinfo(slv_volume, slv_host)
e3c68b
+        slv_info = Volinfo(slv_volume, slv_host, master=False)
e3c68b
         slv_bricks = slv_info.bricks
e3c68b
     # Result of readlink would be of format as below.
e3c68b
     # readlink = "../../pgfid[0:2]/pgfid[2:4]/pgfid/basename"
e3c68b
@@ -854,8 +854,14 @@ class Popen(subprocess.Popen):
e3c68b
 
e3c68b
 class Volinfo(object):
e3c68b
 
e3c68b
-    def __init__(self, vol, host='localhost', prelude=[]):
e3c68b
-        po = Popen(prelude + ['gluster', '--xml', '--remote-host=' + host,
e3c68b
+    def __init__(self, vol, host='localhost', prelude=[], master=True):
e3c68b
+        if master:
e3c68b
+            gluster_cmd_dir = gconf.get("gluster-command-dir")
e3c68b
+        else:
e3c68b
+            gluster_cmd_dir = gconf.get("slave-gluster-command-dir")
e3c68b
+
e3c68b
+        gluster_cmd = os.path.join(gluster_cmd_dir, 'gluster')
e3c68b
+        po = Popen(prelude + [gluster_cmd, '--xml', '--remote-host=' + host,
e3c68b
                               'volume', 'info', vol],
e3c68b
                    stdout=PIPE, stderr=PIPE, universal_newlines=True)
e3c68b
         vix = po.stdout.read()
e3c68b
-- 
e3c68b
1.8.3.1
e3c68b