Deploy healthcheck middleware as app instead of filter
Using the healthcheck middleware as a filter is deprecated and the middleware should be used as an application[1]. [1] 6feaa13610c450c8486f969703768db5319b4846 This change updates definition and usage of the healthcheck middleware accordingly to avoid the following deprecation warning. DeprecationWarning: Using function/method 'Healthcheck.factory()' is deprecated: The healthcheck middleware must now be configured as an application, not as a filter. Closes-Bug: #1937901 Change-Id: Id41e0313a481bea4e2bb14c69f2ad8a2070aa9be
This commit is contained in:
parent
084c8a32f5
commit
fa9450d5b5
@ -1697,19 +1697,21 @@ To enable the health check middleware, it must occur in the beginning of the
|
||||
application pipeline.
|
||||
|
||||
The health check middleware should be placed in your
|
||||
``glance-api-paste.ini`` in a section titled ``[filter:healthcheck]``.
|
||||
``glance-api-paste.ini`` in a section titled ``[app:healthcheck]``.
|
||||
It should look like this::
|
||||
|
||||
[filter:healthcheck]
|
||||
paste.filter_factory = oslo_middleware:Healthcheck.factory
|
||||
[app:healthcheck]
|
||||
paste.app_factory = oslo_middleware:Healthcheck.app_factory
|
||||
backends = disable_by_file
|
||||
disable_by_file_path = /etc/glance/healthcheck_disable
|
||||
|
||||
A ready-made application pipeline including this filter is defined e.g. in
|
||||
A ready-made composite including this application is defined e.g. in
|
||||
the ``glance-api-paste.ini`` file, looking like so::
|
||||
|
||||
[pipeline:glance-api]
|
||||
pipeline = healthcheck versionnegotiation osprofiler unauthenticated-context rootapp
|
||||
[composite:glance-api]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: apiv2app
|
||||
/healthcheck: healthcheck
|
||||
|
||||
For more information see
|
||||
`oslo.middleware <https://docs.openstack.org/oslo.middleware/latest/reference/api.html#oslo_middleware.Healthcheck>`_.
|
||||
|
@ -1,26 +1,56 @@
|
||||
# Use this pipeline for no auth or image caching - DEFAULT
|
||||
[pipeline:glance-api]
|
||||
pipeline = cors healthcheck http_proxy_to_wsgi versionnegotiation osprofiler unauthenticated-context rootapp
|
||||
# Use this composite for no auth or image caching - DEFAULT
|
||||
[composite:glance-api]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api
|
||||
/healthcheck: healthcheck
|
||||
|
||||
# Use this pipeline for image caching and no auth
|
||||
[pipeline:glance-api-caching]
|
||||
pipeline = cors healthcheck http_proxy_to_wsgi versionnegotiation osprofiler unauthenticated-context cache rootapp
|
||||
[pipeline:api]
|
||||
pipeline = cors http_proxy_to_wsgi versionnegotiation osprofiler unauthenticated-context rootapp
|
||||
|
||||
# Use this pipeline for caching w/ management interface but no auth
|
||||
[pipeline:glance-api-cachemanagement]
|
||||
pipeline = cors healthcheck http_proxy_to_wsgi versionnegotiation osprofiler unauthenticated-context cache cachemanage rootapp
|
||||
# Use this composite for image caching and no auth
|
||||
[composite:glance-api-caching]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-caching
|
||||
/healthcheck: healthcheck
|
||||
|
||||
# Use this pipeline for keystone auth
|
||||
[pipeline:glance-api-keystone]
|
||||
pipeline = cors healthcheck http_proxy_to_wsgi versionnegotiation osprofiler authtoken context rootapp
|
||||
[pipeline:api-caching]
|
||||
pipeline = cors http_proxy_to_wsgi versionnegotiation osprofiler unauthenticated-context cache rootapp
|
||||
|
||||
# Use this pipeline for keystone auth with image caching
|
||||
[pipeline:glance-api-keystone+caching]
|
||||
pipeline = cors healthcheck http_proxy_to_wsgi versionnegotiation osprofiler authtoken context cache rootapp
|
||||
# Use this composite for caching w/ management interface but no auth
|
||||
[composite:glance-api-cachemanagement]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-cachemanagement
|
||||
/healthcheck: healthcheck
|
||||
|
||||
# Use this pipeline for keystone auth with caching and cache management
|
||||
[pipeline:glance-api-keystone+cachemanagement]
|
||||
pipeline = cors healthcheck http_proxy_to_wsgi versionnegotiation osprofiler authtoken context cache cachemanage rootapp
|
||||
[pipeline:api-cachemanagement]
|
||||
pipeline = cors http_proxy_to_wsgi versionnegotiation osprofiler unauthenticated-context cache cachemanage rootapp
|
||||
|
||||
# Use this composite for keystone auth
|
||||
[composite:glance-api-keystone]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-keystone
|
||||
/healthcheck: healthcheck
|
||||
|
||||
[pipeline:api-keystone]
|
||||
pipeline = cors http_proxy_to_wsgi versionnegotiation osprofiler authtoken context rootapp
|
||||
|
||||
# Use this composite for keystone auth with image caching
|
||||
[composite:glance-api-keystone+caching]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-keystone+caching
|
||||
/healthcheck: healthcheck
|
||||
|
||||
[pipeline:api-keystone+caching]
|
||||
pipeline = cors http_proxy_to_wsgi versionnegotiation osprofiler authtoken context cache rootapp
|
||||
|
||||
# Use this composite for keystone auth with caching and cache management
|
||||
[composite:glance-api-keystone+cachemanagement]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-keystone+cachemanagement
|
||||
/healthcheck: healthcheck
|
||||
|
||||
[pipeline:api-keystone+cachemanagement]
|
||||
pipeline = cors http_proxy_to_wsgi versionnegotiation osprofiler authtoken context cache cachemanage rootapp
|
||||
|
||||
[composite:rootapp]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
@ -33,8 +63,8 @@ paste.app_factory = glance.api.versions:create_resource
|
||||
[app:apiv2app]
|
||||
paste.app_factory = glance.api.v2.router:API.factory
|
||||
|
||||
[filter:healthcheck]
|
||||
paste.filter_factory = oslo_middleware:Healthcheck.factory
|
||||
[app:healthcheck]
|
||||
paste.app_factory = oslo_middleware:Healthcheck.app_factory
|
||||
backends = disable_by_file
|
||||
disable_by_file_path = /etc/glance/healthcheck_disable
|
||||
|
||||
|
@ -468,23 +468,35 @@ default_store = %(default_store)s
|
||||
[import_filtering_opts]
|
||||
allowed_ports = []
|
||||
"""
|
||||
self.paste_conf_base = """[pipeline:glance-api]
|
||||
self.paste_conf_base = """[composite:glance-api]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api
|
||||
/healthcheck: healthcheck
|
||||
|
||||
[pipeline:api]
|
||||
pipeline =
|
||||
cors
|
||||
healthcheck
|
||||
versionnegotiation
|
||||
gzip
|
||||
unauthenticated-context
|
||||
rootapp
|
||||
|
||||
[pipeline:glance-api-caching]
|
||||
pipeline = cors healthcheck versionnegotiation gzip context
|
||||
cache rootapp
|
||||
[composite:glance-api-caching]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-caching
|
||||
/healthcheck: healthcheck
|
||||
|
||||
[pipeline:glance-api-cachemanagement]
|
||||
[pipeline:api-caching]
|
||||
pipeline = cors versionnegotiation gzip context cache rootapp
|
||||
|
||||
[composite:glance-api-cachemanagement]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-cachemanagement
|
||||
/healthcheck: healthcheck
|
||||
|
||||
[pipeline:api-cachemanagement]
|
||||
pipeline =
|
||||
cors
|
||||
healthcheck
|
||||
versionnegotiation
|
||||
gzip
|
||||
unauthenticated-context
|
||||
@ -492,11 +504,21 @@ pipeline =
|
||||
cache_manage
|
||||
rootapp
|
||||
|
||||
[pipeline:glance-api-fakeauth]
|
||||
pipeline = cors healthcheck versionnegotiation gzip fakeauth context rootapp
|
||||
[composite:glance-api-fakeauth]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-fakeauth
|
||||
/healthcheck: healthcheck
|
||||
|
||||
[pipeline:glance-api-noauth]
|
||||
pipeline = cors healthcheck versionnegotiation gzip context rootapp
|
||||
[pipeline:api-fakeauth]
|
||||
pipeline = cors versionnegotiation gzip fakeauth context rootapp
|
||||
|
||||
[composite:glance-api-noauth]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-noauth
|
||||
/healthcheck: healthcheck
|
||||
|
||||
[pipeline:api-noauth]
|
||||
pipeline = cors versionnegotiation gzip context rootapp
|
||||
|
||||
[composite:rootapp]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
@ -509,8 +531,8 @@ paste.app_factory = glance.api.versions:create_resource
|
||||
[app:apiv2app]
|
||||
paste.app_factory = glance.api.v2.router:API.factory
|
||||
|
||||
[filter:healthcheck]
|
||||
paste.filter_factory = oslo_middleware:Healthcheck.factory
|
||||
[app:healthcheck]
|
||||
paste.app_factory = oslo_middleware:Healthcheck.app_factory
|
||||
backends = disable_by_file
|
||||
disable_by_file_path = %(disable_path)s
|
||||
|
||||
@ -643,23 +665,35 @@ allowed_ports = []
|
||||
[os_glance_staging_store]
|
||||
filesystem_store_datadir=%(staging_dir)s
|
||||
"""
|
||||
self.paste_conf_base = """[pipeline:glance-api]
|
||||
self.paste_conf_base = """[composite:glance-api]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api
|
||||
/healthcheck: healthcheck
|
||||
|
||||
[pipeline:api]
|
||||
pipeline =
|
||||
cors
|
||||
healthcheck
|
||||
versionnegotiation
|
||||
gzip
|
||||
unauthenticated-context
|
||||
rootapp
|
||||
|
||||
[pipeline:glance-api-caching]
|
||||
pipeline = cors healthcheck versionnegotiation gzip unauthenticated-context
|
||||
cache rootapp
|
||||
[composite:glance-api-caching]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-caching
|
||||
/healthcheck: healthcheck
|
||||
|
||||
[pipeline:glance-api-cachemanagement]
|
||||
[pipeline:api-caching]
|
||||
pipeline = cors versionnegotiation gzip unauthenticated-context cache rootapp
|
||||
|
||||
[composite:glance-api-cachemanagement]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-cachemanagement
|
||||
/healthcheck: healthcheck
|
||||
|
||||
[pipeline:api-cachemanagement]
|
||||
pipeline =
|
||||
cors
|
||||
healthcheck
|
||||
versionnegotiation
|
||||
gzip
|
||||
unauthenticated-context
|
||||
@ -667,11 +701,21 @@ pipeline =
|
||||
cache_manage
|
||||
rootapp
|
||||
|
||||
[pipeline:glance-api-fakeauth]
|
||||
pipeline = cors healthcheck versionnegotiation gzip fakeauth context rootapp
|
||||
[composite:glance-api-fakeauth]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-fakeauth
|
||||
/healthcheck: healthcheck
|
||||
|
||||
[pipeline:glance-api-noauth]
|
||||
pipeline = cors healthcheck versionnegotiation gzip context rootapp
|
||||
[pipeline:api-fakeauth]
|
||||
pipeline = cors versionnegotiation gzip fakeauth context rootapp
|
||||
|
||||
[composite:glance-api-noauth]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-noauth
|
||||
/healthcheck: healthcheck
|
||||
|
||||
[pipeline:api-noauth]
|
||||
pipeline = cors versionnegotiation gzip context rootapp
|
||||
|
||||
[composite:rootapp]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
@ -684,8 +728,8 @@ paste.app_factory = glance.api.versions:create_resource
|
||||
[app:apiv2app]
|
||||
paste.app_factory = glance.api.v2.router:API.factory
|
||||
|
||||
[filter:healthcheck]
|
||||
paste.filter_factory = oslo_middleware:Healthcheck.factory
|
||||
[app:healthcheck]
|
||||
paste.app_factory = oslo_middleware:Healthcheck.app_factory
|
||||
backends = disable_by_file
|
||||
disable_by_file_path = %(disable_path)s
|
||||
|
||||
|
@ -31,13 +31,25 @@ from glance.tests import utils as test_utils
|
||||
|
||||
|
||||
TESTING_API_PASTE_CONF = """
|
||||
[pipeline:glance-api]
|
||||
[composite:glance-api]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api
|
||||
|
||||
[pipeline: api]
|
||||
pipeline = versionnegotiation gzip unauthenticated-context rootapp
|
||||
|
||||
[pipeline:glance-api-caching]
|
||||
[composite:glance-api-caching]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-caching
|
||||
|
||||
[pipeline: api-caching]
|
||||
pipeline = versionnegotiation gzip unauthenticated-context cache rootapp
|
||||
|
||||
[pipeline:glance-api-cachemanagement]
|
||||
[composite:glance-api-cachemanagement]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-cachemanagement
|
||||
|
||||
[pipeline: api-cachemanagement]
|
||||
pipeline =
|
||||
versionnegotiation
|
||||
gzip
|
||||
@ -46,10 +58,18 @@ pipeline =
|
||||
cache_manage
|
||||
rootapp
|
||||
|
||||
[pipeline:glance-api-fakeauth]
|
||||
[composite:glance-api-fakeauth]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-fakeauth
|
||||
|
||||
[pipeline: api-fakeauth]
|
||||
pipeline = versionnegotiation gzip fakeauth context rootapp
|
||||
|
||||
[pipeline:glance-api-noauth]
|
||||
[composite:glance-api-noauth]
|
||||
paste.composite_factory = glance.api:root_app_factory
|
||||
/: api-noauth
|
||||
|
||||
[pipeline: api-noauth]
|
||||
pipeline = versionnegotiation gzip context rootapp
|
||||
|
||||
[composite:rootapp]
|
||||
|
@ -66,7 +66,7 @@ class TestPasteApp(test_utils.BaseTestCase):
|
||||
|
||||
app = config.load_paste_app('glance-api')
|
||||
|
||||
self.assertIsInstance(app, expected_app_type)
|
||||
self.assertIsInstance(app['/'], expected_app_type)
|
||||
|
||||
def test_load_paste_app(self):
|
||||
expected_middleware = oslo_middleware.CORS
|
||||
@ -78,7 +78,11 @@ class TestPasteApp(test_utils.BaseTestCase):
|
||||
expected_middleware, make_paste_file=False)
|
||||
|
||||
def test_load_paste_app_with_paste_flavor(self):
|
||||
pipeline = ('[pipeline:glance-api-incomplete]\n'
|
||||
pipeline = ('[composite:glance-api-incomplete]\n'
|
||||
'paste.composite_factory = glance.api:root_app_factory\n'
|
||||
'/: api-incomplete\n'
|
||||
'/healthcheck: healthcheck\n'
|
||||
'[pipeline:api-incomplete]\n'
|
||||
'pipeline = context rootapp')
|
||||
expected_middleware = context.ContextMiddleware
|
||||
self._do_test_load_paste_app(expected_middleware,
|
||||
|
Loading…
x
Reference in New Issue
Block a user