Skip to content

Commit

Permalink
Better error handling for DBS3Upload block injection
Browse files Browse the repository at this point in the history
  • Loading branch information
amaltaro committed Jun 16, 2022
1 parent 0773b0d commit 9931e7a
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/python/WMComponent/DBS3Buffer/DBSUploadPoller.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,35 @@ def uploadWorker(workInput, results, dbsUrl, gzipEncoding=False):
logging.warning("Block %s already exists. Marking it as uploaded.", name)
logging.debug("Exception: %s", exString)
results.put({'name': name, 'success': "uploaded"})
elif 'Proxy Error' in exString:
# This is probably a successfully insertion that went bad.
# Put it on the check list
msg = "Got a proxy error for block %s." % name
logging.warning(msg)
results.put({'name': name, 'success': "check"})
elif 'Missing data when inserting to dataset_parents' in exString:
msg = "Parent dataset is not inserted yet for block %s." % name
logging.warning(msg)
results.put({'name': name, 'success': "error", 'error': msg})
else:
msg = "Error trying to process block %s through DBS. Error: %s" % (name, exString)
reason = parseDBSException(exString)
msg = "Error trying to process block %s through DBS. Error: %s" % (name, reason)
logging.exception(msg)
logging.debug("block info: %s \n", block)
results.put({'name': name, 'success': "error", 'error': msg})

return


def parseDBSException(exBodyString):
"""
parse DBS Go-based server exception
:param exBodyString: exception message body string (not exception).
The upstream code extract HTTP body from exception object and pass it here.
:return: either (parsed) concise exception message or original body string
"""
try:
data = json.loads(exBodyString)
# dbs2go always return a list
return data[0]['error']['reason']
except:
return exBodyString


def isPassiveError(exceptionObj):
"""
This function will parse the exception object and report whether
Expand Down

0 comments on commit 9931e7a

Please sign in to comment.