From 9931e7ad6918820f34c14f2b9efe84a0e18842c3 Mon Sep 17 00:00:00 2001 From: Alan Malta Rodrigues Date: Wed, 15 Jun 2022 23:40:27 -0400 Subject: [PATCH] Better error handling for DBS3Upload block injection --- .../WMComponent/DBS3Buffer/DBSUploadPoller.py | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/python/WMComponent/DBS3Buffer/DBSUploadPoller.py b/src/python/WMComponent/DBS3Buffer/DBSUploadPoller.py index 70947729f4..b0aeaf996c 100644 --- a/src/python/WMComponent/DBS3Buffer/DBSUploadPoller.py +++ b/src/python/WMComponent/DBS3Buffer/DBSUploadPoller.py @@ -99,18 +99,13 @@ 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}) @@ -118,6 +113,21 @@ def uploadWorker(workInput, results, dbsUrl, gzipEncoding=False): 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