Add additional logging around secscan analyze

This commit is contained in:
Joseph Schorr 2017-04-21 16:52:47 -04:00
parent 94ab6cf635
commit f296599162
2 changed files with 5 additions and 0 deletions

View file

@ -64,6 +64,8 @@ class LayerAnalyzer(object):
except AnalyzeLayerException:
# Something went wrong when trying to analyze the layer and we cannot retry, so mark the
# layer as invalid.
logger.exception('Got exception when trying to analyze layer %s via security scanner',
layer.id)
if not set_secscan_status(layer, False, self._target_version):
raise PreemptedException

View file

@ -280,6 +280,7 @@ class ImplementedSecurityScannerAPI(SecurityScannerAPIInterface):
request = self._new_analyze_request(layer)
if not request:
logger.error('Could not build analyze request for layer %s', layer.id)
raise AnalyzeLayerException
logger.info('Analyzing layer %s', request['Layer']['Name'])
@ -303,12 +304,14 @@ class ImplementedSecurityScannerAPI(SecurityScannerAPIInterface):
if message == UNKNOWN_PARENT_LAYER_ERROR_MSG:
raise MissingParentLayerException('Bad request to security scanner: %s' % message)
else:
logger.exception('Got non-200 response for analyze of layer %s', layer.id)
raise AnalyzeLayerException('Bad request to security scanner: %s' % message)
# 422 means that the layer could not be analyzed:
# - the layer could not be extracted (might be a manifest or an invalid .tar.gz)
# - the layer operating system / package manager is unsupported
elif ex.response.status_code == 422:
raise InvalidLayerException
# Otherwise, it is some other error and we should retry.
raise AnalyzeLayerRetryException