Cleanup TODO in glance/gateway.py for elasticsearch being unavailable
In commit f53584c268
we added a TODO to be
more obvious about the error when elasticsearch isn't available if you
try to start the search service (since elasticsearch is an optional
dependency). We couldn't add new errors at the time because of
StringFreeze.
This resolves the TODO by adding the new SearchNotAvailable exception in
place of the generic ServiceUnavailable exception.
Closes-Bug: #1441764
Change-Id: Ia300d9647f372a677dc536e750dd2ff064601c29
This commit is contained in:
parent
e52762aeef
commit
4a932b0d4b
|
@ -558,3 +558,9 @@ class InvalidJsonPatchPath(JsonPatchException):
|
|||
def __init__(self, message=None, *args, **kwargs):
|
||||
self.explanation = kwargs.get("explanation")
|
||||
super(InvalidJsonPatchPath, self).__init__(message, *args, **kwargs)
|
||||
|
||||
|
||||
class SearchNotAvailable(GlanceException):
|
||||
message = _("The search and index services are not available. Ensure you "
|
||||
"have the necessary prerequisite dependencies installed like "
|
||||
"elasticsearch to use these services.")
|
||||
|
|
|
@ -24,6 +24,7 @@ from glance.common import property_utils
|
|||
from glance.common import store_utils
|
||||
import glance.db
|
||||
import glance.domain
|
||||
from glance.i18n import _LE
|
||||
import glance.location
|
||||
import glance.notifier
|
||||
import glance.quota
|
||||
|
@ -248,14 +249,11 @@ class Gateway(object):
|
|||
|
||||
def get_catalog_search_repo(self, context):
|
||||
if self.es_api is None:
|
||||
# TODO(mriedem): Make this a separate exception or change to
|
||||
# warning/error logging in Liberty once we're past string freeze.
|
||||
# See bug 1441764.
|
||||
LOG.debug('The search and index services are not available. '
|
||||
'Ensure you have the necessary prerequisite '
|
||||
'dependencies installed like elasticsearch to use these '
|
||||
'services.')
|
||||
raise exception.ServiceUnavailable()
|
||||
LOG.error(_LE('The search and index services are not available. '
|
||||
'Ensure you have the necessary prerequisite '
|
||||
'dependencies installed like elasticsearch to use '
|
||||
'these services.'))
|
||||
raise exception.SearchNotAvailable()
|
||||
search_repo = glance.search.CatalogSearchRepo(context, self.es_api)
|
||||
policy_search_repo = policy.CatalogSearchRepoProxy(
|
||||
search_repo, context, self.policy)
|
||||
|
|
|
@ -25,6 +25,6 @@ class TestGateway(test_utils.BaseTestCase):
|
|||
@mock.patch.object(gateway, 'glance_search', None)
|
||||
def test_get_catalog_search_repo_no_es_api(self):
|
||||
gate = gateway.Gateway()
|
||||
self.assertRaises(exception.ServiceUnavailable,
|
||||
self.assertRaises(exception.SearchNotAvailable,
|
||||
gate.get_catalog_search_repo,
|
||||
context.get_admin_context())
|
||||
|
|
Loading…
Reference in New Issue