Avoid BadRequest error log on volume attachment
At the gate, only AttachVolumeNegativeTest makes nova-api output error log as a negative test case like: ERROR nova.volume.cinder [None req-dcc8814f-7439-44c8-872e-86ea51f4b319 tempest-AttachVolumeNegativeTest-431575524 tempest-AttachVolumeNegativeTest-431575524] [instance: ca526f93-e723-4372-a1c1-4fa03ffc1bd7] Create attachment failed for volume 0a6e6a92-f095-4ab7-803c-826934824418. Error: Invalid volume: Volume 0a6e6a92-f095-4ab7-803c-826934824418 status must be available or downloading (HTTP 400) (Request-ID: req-5e5074ea-cd12-43ed-9355-5db539ca9720) Code: 400: BadRequest: Invalid volume: Volume 0a6e6a92-f095-4ab7-803c-826934824418 status must be available or downloading (HTTP 400) (Request-ID: req-5e5074ea-cd12-43ed-9355-5db539ca9720) Operators don't need to take care of BadRequest cases in general because that is due to end user mistakes. So this patch makes nova-api avoiding such error log case. Closes-Bug: #1797237 Change-Id: I22d9d974822282ffc3c0942d4766b135717dd369
This commit is contained in:

committed by
Matt Riedemann

parent
8469fa70da
commit
5bef746c9b
@@ -746,12 +746,15 @@ class API(object):
|
||||
return _translate_attachment_ref(attachment_ref)
|
||||
except cinder_exception.ClientException as ex:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error(('Create attachment failed for volume '
|
||||
'%(volume_id)s. Error: %(msg)s Code: %(code)s'),
|
||||
{'volume_id': volume_id,
|
||||
'msg': six.text_type(ex),
|
||||
'code': getattr(ex, 'code', None)},
|
||||
instance_uuid=instance_id)
|
||||
# NOTE: It is unnecessary to output BadRequest(400) error log,
|
||||
# because operators don't need to debug such cases.
|
||||
if getattr(ex, 'code', None) != 400:
|
||||
LOG.error(('Create attachment failed for volume '
|
||||
'%(volume_id)s. Error: %(msg)s Code: %(code)s'),
|
||||
{'volume_id': volume_id,
|
||||
'msg': six.text_type(ex),
|
||||
'code': getattr(ex, 'code', None)},
|
||||
instance_uuid=instance_id)
|
||||
|
||||
@translate_attachment_exception
|
||||
def attachment_get(self, context, attachment_id):
|
||||
|
Reference in New Issue
Block a user