From 5140b0c1f65a854c3e6cc5e1d1d852569a0abaee Mon Sep 17 00:00:00 2001 From: sayaleeraut Date: Wed, 19 Aug 2020 13:12:33 +0530 Subject: [LibFix] Fix code to avoid failure Description: Earlier, on running a test script which calls get_volume_type(), the test script displayed below failure message in glusto logs: "INFO (get_volume_type) Failed to find brick-path 10.70.47.44:/bricks/brick2/testvol_distributed_brick0// for volume testvol_distributed" - even though the brick-path was present in the volume. Checked by directly calling the function as well: >>> from glusto.core import Glusto as g >>> from glustolibs.gluster.volume_libs import get_volume_type >>> ret = get_volume_type('10.70.47.44:/bricks/brick2/vol1-b1/') >>> print ret Distribute >>> ret = get_volume_type('10.70.47.44:/bricks/brick2/vol1-b1//') >>> print ret None Observed that the issue occurs if an extra "/" is present at the end of the brickdir_path(str) parameter passed to the function. Hence have added a check for the same. Change-Id: I01fe2d05b7f206d7767c83e57e714053358dc42c Signed-off-by: sayaleeraut --- glustolibs-gluster/glustolibs/gluster/volume_libs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'glustolibs-gluster/glustolibs/gluster') diff --git a/glustolibs-gluster/glustolibs/gluster/volume_libs.py b/glustolibs-gluster/glustolibs/gluster/volume_libs.py index 0505edfce..376ac5089 100644 --- a/glustolibs-gluster/glustolibs/gluster/volume_libs.py +++ b/glustolibs-gluster/glustolibs/gluster/volume_libs.py @@ -1686,7 +1686,8 @@ def get_volume_type(brickdir_path): # Adding import here to avoid cyclic imports from glustolibs.gluster.brick_libs import get_all_bricks (host, brick_path_info) = brickdir_path.split(':') - path_info = brick_path_info[:-1] + path_info = (brick_path_info[:-2] if brick_path_info.endswith("//") + else brick_path_info[:-1]) for volume in get_volume_list(host): brick_paths = [brick.split(':')[1] for brick in get_all_bricks(host, volume)] -- cgit