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