path: root/glustolibs-gluster/glustolibs/gluster
diff options
authorkshithijiyer <>2020-08-10 14:44:12 +0530
committerBala Konda Reddy M <>2020-08-11 05:11:42 +0000
commitd4ee7ad936e45019275e536f0041addee54812c4 (patch)
treed05e8fa7db63beeb4f5e2799079ae9a804df957a /glustolibs-gluster/glustolibs/gluster
parent859fe721ae12b4d4eeb342954805ce2b51120d7e (diff)
[Libfix] Fix UnicodeDecodeError in get_fattr()
Problem: Some testcases fail with UnicodeDecodeError when the framework is run using python3. This happens becuase the get_fattr() command returns non-unicode output which leads to data.decode() used in subprocess.Popen to fail. This isn't the case in python2 as it doesn't bother about encoding and dumps whatever is the output back to the management node. ``` gfid = get_fattr(brick_tuple[0], brick_path + '/' + direc, 'trusted.gfid') /root/glusto-tests/tests/functional/dht/ /usr/local/lib/python3.8/site-packages/glustolibs_gluster-0.22-py3.8.egg/glustolibs/gluster/ in get_fattr rcode, rout, rerr =, command) /usr/local/lib/python3.8/site-packages/glusto-0.72-py3.8.egg/glusto/ in run stdout, stderr = proc.communicate() /usr/lib64/python3.8/ in communicate stdout, stderr = self._communicate(input, endtime, timeout) /usr/lib64/python3.8/ in _communicate stdout = self._translate_newlines(stdout, self = <subprocess.Popen object at 0x7f22b4e2f490>, data = b'\xber\t\nO\xebO\xee\xa4\x9c\xc4L\xac\x1cj\xd5', encoding = 'UTF-8', errors = 'strict' def _translate_newlines(self, data, encoding, errors): data = data.decode(encoding, errors) E UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbe in position 0: invalid start byte /usr/lib64/python3.8/ UnicodeDecodeError ``` Solution: Change get_fattr() command to return xattr value in hex to avoid UnicodeDecodeError error from Popen. Fixes: Change-Id: I8c4786c882adf6079404b97eca2c399535db068f Signed-off-by: kshithijiyer <>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster')
1 files changed, 4 insertions, 3 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/ b/glustolibs-gluster/glustolibs/gluster/
index 7cb961c03..32068d9f4 100755
--- a/glustolibs-gluster/glustolibs/gluster/
+++ b/glustolibs-gluster/glustolibs/gluster/
@@ -108,12 +108,13 @@ def get_fattr(host, fqpath, fattr):
getfattr result on success. None on fail.
- command = ("getfattr --absolute-names --only-values -n '%s' %s" %
+ command = ("getfattr --absolute-names -e hex "
+ "-n '%s' %s" %
(fattr, fqpath))
rcode, rout, rerr =, command)
- if rcode == 0:
- return rout.strip()
+ if not rcode:
+ return rout.strip().split('=')[1]
g.log.error('getfattr failed: %s' % rerr)
return None