fix(wsgi): a non-existing queue stats returns 404
Fixes: Bug#1192180 Change-Id: Iaf1e77b8ce01b33de63979164ea23ea086bf81d4
This commit is contained in:
@@ -33,6 +33,10 @@ class QueueLifecycleBaseTest(base.TestBase):
|
|||||||
path = '/v1/queues/gumshoe'
|
path = '/v1/queues/gumshoe'
|
||||||
|
|
||||||
for project_id in ('480924', 'foo', '', None):
|
for project_id in ('480924', 'foo', '', None):
|
||||||
|
# Stats
|
||||||
|
self.simulate_get(path + '/stats', project_id)
|
||||||
|
self.assertEquals(self.srmock.status, falcon.HTTP_404)
|
||||||
|
|
||||||
# Create
|
# Create
|
||||||
doc = '{"messages": {"ttl": 600}}'
|
doc = '{"messages": {"ttl": 600}}'
|
||||||
self.simulate_put(path, project_id, body=doc)
|
self.simulate_put(path, project_id, body=doc)
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
import falcon
|
import falcon
|
||||||
|
|
||||||
import marconi.openstack.common.log as logging
|
import marconi.openstack.common.log as logging
|
||||||
|
from marconi.storage import exceptions as storage_exceptions
|
||||||
from marconi.transport import helpers
|
from marconi.transport import helpers
|
||||||
|
from marconi.transport.wsgi import exceptions as wsgi_exceptions
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@@ -38,8 +40,10 @@ class Resource(object):
|
|||||||
resp.body = helpers.to_json(resp_dict)
|
resp.body = helpers.to_json(resp_dict)
|
||||||
resp.status = falcon.HTTP_200
|
resp.status = falcon.HTTP_200
|
||||||
|
|
||||||
|
except storage_exceptions.DoesNotExist:
|
||||||
|
raise falcon.HTTPNotFound()
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.exception(ex)
|
LOG.exception(ex)
|
||||||
title = _('Service temporarily unavailable')
|
description = _('Queue stats could not be read.')
|
||||||
msg = _('Please try again in a few seconds.')
|
raise wsgi_exceptions.HTTPServiceUnavailable(description)
|
||||||
raise falcon.HTTPServiceUnavailable(title, msg, 30)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user