From a25cba6e0891ead62d34761b34c4f623a4225675 Mon Sep 17 00:00:00 2001 From: Giuseppe Lo Presti Date: Fri, 26 Nov 2021 17:51:51 +0100 Subject: [PATCH] Fixed xrootd xattr methods --- src/core/xrootiface.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/core/xrootiface.py b/src/core/xrootiface.py index a69dec41..156cd036 100644 --- a/src/core/xrootiface.py +++ b/src/core/xrootiface.py @@ -89,8 +89,8 @@ def _xrootcmd(endpoint, cmd, subcmd, userid, args): if rc != '0': # failure: get info from stderr, log and raise msg = res[1][res[1].find('=')+1:].strip('\n') - if ENOENT_MSG.lower() in msg: - log.info('msg="Invoked xroot on non-existing file" cmd="%s" subcmd="%s" args="%s" error="%s" rc="%s"' % \ + if ENOENT_MSG.lower() in msg or 'unable to get attribute' in msg: + log.info('msg="Invoked xroot on non-existing entity" cmd="%s" subcmd="%s" args="%s" error="%s" rc="%s"' % \ (cmd, subcmd, args, msg, rc.strip('\00'))) else: log.error('msg="Error with xroot" cmd="%s" subcmd="%s" args="%s" error="%s" rc="%s"' % \ @@ -246,12 +246,11 @@ def setxattr(endpoint, filepath, userid, key, value): def getxattr(endpoint, filepath, userid, key): '''Get the extended attribute via a special open on behalf of the given userid''' - res = _xrootcmd(endpoint, 'attr', 'get', userid, 'mgm.attr.key=user.' + key + '&mgm.path=' + _getfilepath(filepath, encodeamp=True)) - # if no error, the response comes in the format ="" try: + res = _xrootcmd(endpoint, 'attr', 'get', userid, 'mgm.attr.key=user.' + key + '&mgm.path=' + _getfilepath(filepath, encodeamp=True)) + # if no error, the response comes in the format ="" return res.split('"')[1] - except IndexError: - log.warning('msg="Failed to getxattr" filepath="%s" key="%s" res="%s"' % (filepath, key, res)) + except (IndexError, IOError): return None @@ -265,7 +264,7 @@ def setlock(endpoint, filepath, userid, value): try: setxattr(endpoint, filepath, userid, LOCKKEY, str(value) + '&mgm.option=c') except IOError as e: - if 'exclusive set for exsisting attribute' in str(e): + if 'exclusive set for existing attribute' in str(e): raise IOError('File exists and islock flag requested')