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