Skip to content

Commit

Permalink
Fixed xrootd xattr methods
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Nov 26, 2021
1 parent 114beb9 commit a25cba6
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/core/xrootiface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"' % \
Expand Down Expand Up @@ -246,12 +246,11 @@ def setxattr(endpoint, filepath, userid, key, value):

def getxattr(endpoint, filepath, userid, key):
'''Get the extended attribute <key> 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 <key>="<value>"
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 <key>="<value>"
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


Expand All @@ -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')


Expand Down

0 comments on commit a25cba6

Please sign in to comment.