log response data on non-200 responses in TUF API

This commit is contained in:
Evan Cordell 2018-02-20 09:46:53 -05:00
parent ac328da383
commit b545cad380

View file

@ -36,7 +36,7 @@ class Non200ResponseException(Exception):
class TUFMetadataAPI(object):
""" Helper class for talking to the Security Scan service (usually Clair). """
""" Helper class for talking to the TUF Metadata service (Apostille). """
def __init__(self, app, config, client=None):
feature_enabled = config.get('FEATURE_SIGNING', False)
if feature_enabled:
@ -202,7 +202,7 @@ class ImplementedTUFMetadataAPI(TUFMetadataAPIInterface):
logger.exception('Failed to delete metadata for %s', gun)
return False
except Non200ResponseException as ex:
logger.exception('Failed request for %s: %s', gun, str(ex))
logger.exception('Failed request for %s: %s %s', gun, ex.response, str(ex))
return False
return True
@ -223,7 +223,7 @@ class ImplementedTUFMetadataAPI(TUFMetadataAPIInterface):
except (requests.exceptions.RequestException, ValueError):
logger.exception('Failed to get metadata for %s', gun)
except Non200ResponseException as ex:
logger.exception('Failed request for %s: %s', gun, str(ex))
logger.exception('Failed request for %s: %s %s', gun, ex.response, str(ex))
except InvalidMetadataException as ex:
logger.exception('Failed to parse targets from metadata: %s', str(ex))
return None