Return HTTP 500 from /v1/continue on unexpected exceptions

Currently it returns HTTP 400 which is obviously wrong.

Closes-Bug: #1590302
Change-Id: I56114aa1c0a3248cc80f79d1a5da3ace6c615e52
This commit is contained in:
Dmitry Tantsur 2016-06-08 09:56:04 +02:00
parent 457c1277de
commit 223ff38dcf
3 changed files with 10 additions and 3 deletions

View File

@ -234,7 +234,8 @@ def process(introspection_data):
'error': exc}
node_info.finished(error=msg)
_store_logs(introspection_data, node_info)
raise utils.Error(msg, node_info=node_info, data=introspection_data)
raise utils.Error(msg, node_info=node_info, data=introspection_data,
code=500)
if CONF.processing.always_store_ramdisk_logs:
_store_logs(introspection_data, node_info)

View File

@ -134,9 +134,11 @@ class TestProcess(BaseProcessTest):
def test_unexpected_exception(self):
self.process_mock.side_effect = RuntimeError('boom')
self.assertRaisesRegexp(utils.Error, 'Unexpected exception',
process.process, self.data)
with self.assertRaisesRegexp(utils.Error,
'Unexpected exception') as ctx:
process.process(self.data)
self.assertEqual(500, ctx.exception.http_code)
self.node_info.finished.assert_called_once_with(
error='Unexpected exception RuntimeError during processing: boom')

View File

@ -0,0 +1,4 @@
---
fixes:
- Fixed "/v1/continue" to return HTTP 500 on unexpected exceptions, not
HTTP 400.