summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/heal_libs.py
diff options
context:
space:
mode:
authorkshithijiyer <kshithij.ki@gmail.com>2020-04-01 10:44:54 +0530
committerkshithijiyer <kshithij.ki@gmail.com>2020-04-01 12:17:18 +0530
commitdd2382c613db6f3dd72a25c74d5f765006aea31f (patch)
treefcbdca0fc93539b7eee159bfa3c381167cd0eb1c /glustolibs-gluster/glustolibs/gluster/heal_libs.py
parentd4349ba649c967ed6c16c1efdd9caa56433142f1 (diff)
[Libfix] Remove rpyc_get_connection() dependency from code
Problem: `g.rpyc_get_connection()` has a limitaion where it can't convert python2 calls to python3 calls. Due to this a large number of testcases fail when executed from a python2 machine on a python3 only setup or visa versa with the below stack trace: ``` E ========= Remote Traceback (1) ========= E Traceback (most recent call last): E File "/root/tmp.tL8Eqx7d8l/rpyc/core/protocol.py", line 323, in _dispatch_request E res = self._HANDLERS[handler](self, *args) E File "/root/tmp.tL8Eqx7d8l/rpyc/core/protocol.py", line 591, in _handle_inspect E if hasattr(self._local_objects[id_pack], '____conn__'): E File "/root/tmp.tL8Eqx7d8l/rpyc/lib/colls.py", line 110, in __getitem__ E return self._dict[key][0] E KeyError: (b'rpyc.core.service.SlaveService', 94282642994712, 140067150858560) ``` Solution: The solution here is to modify the code to not use `g.rpyc_get_connection()`. The following changes are done to accomplish it: 1)Remove code which uses g.rpyc_get_connection() and use generic logic in functions: a. do_bricks_exist_in_shd_volfile() b. get_disk_usage() c. mount_volume() d. list_files() f. append_string_to_file() 2)Create files which can be uploaded and executed on clients/servers to avoid rpc calls in functions: a. calculate_hash() b. validate_files_in_dir() 3)Modify setup.py to push the below files to `/usr/share/glustolibs/scripts/`: a.compute_hash.py b.walk_dir.py Change-Id: I00a81a88382bf3f8b366753eebdb2999260788ca Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/heal_libs.py')
-rwxr-xr-xglustolibs-gluster/glustolibs/gluster/heal_libs.py44
1 files changed, 20 insertions, 24 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/heal_libs.py b/glustolibs-gluster/glustolibs/gluster/heal_libs.py
index 2b0e9ed33..504173ae7 100755
--- a/glustolibs-gluster/glustolibs/gluster/heal_libs.py
+++ b/glustolibs-gluster/glustolibs/gluster/heal_libs.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2016 Red Hat, Inc. <http://www.redhat.com>
+# Copyright (C) 2016-2020 Red Hat, Inc. <http://www.redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -395,30 +395,26 @@ def do_bricks_exist_in_shd_volfile(mnode, volname, brick_list):
host = brick = None
parse = False
- # Establish connection to mnode
- conn = g.rpyc_get_connection(mnode)
- if conn is None:
- g.log.info("Not able to establish connection to node %s" % mnode)
- return False
- try:
- fd = conn.builtins.open(GLUSTERSHD)
- for each_line in fd:
- each_line = each_line.strip()
- if volume_clients in each_line:
- parse = True
- elif "end-volume" in each_line:
- if parse:
- brick_list_server_vol.append("%s:%s" % (host, brick))
- parse = False
- elif parse:
- if "option remote-subvolume" in each_line:
- brick = each_line.split(" ")[2]
- if "option remote-host" in each_line:
- host = each_line.split(" ")[2]
-
- except IOError as e:
- g.log.info("I/O error ({0}): {1}".format(e.errno, e.strerror))
+ cmd = "cat {0}".format(GLUSTERSHD)
+ ret, out, _ = g.run(mnode, cmd)
+ if ret:
+ g.log.error("Unable to cat the GLUSTERSHD file.")
return False
+ fd = out.split('\n')
+
+ for each_line in fd:
+ each_line = each_line.strip()
+ if volume_clients in each_line:
+ parse = True
+ elif "end-volume" in each_line:
+ if parse:
+ brick_list_server_vol.append("%s:%s" % (host, brick))
+ parse = False
+ elif parse:
+ if "option remote-subvolume" in each_line:
+ brick = each_line.split(" ")[2]
+ if "option remote-host" in each_line:
+ host = each_line.split(" ")[2]
g.log.info("Brick List from volume info : %s" % brick_list)
g.log.info("Brick List from glustershd server volume "