summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/source/cors.rst4
-rw-r--r--doc/source/oslo_config.rst4
-rw-r--r--oslo_middleware/healthcheck/__init__.py66
-rw-r--r--oslo_middleware/healthcheck/opts.py1
-rw-r--r--setup.cfg3
5 files changed, 57 insertions, 21 deletions
diff --git a/doc/source/cors.rst b/doc/source/cors.rst
index ea19d9e..77bb6ed 100644
--- a/doc/source/cors.rst
+++ b/doc/source/cors.rst
@@ -62,7 +62,7 @@ If your application is using pastedeploy, the following configuration block
will add CORS support.::
[filter:cors]
- paste.filter_factory = oslo_middleware.cors:filter_factory
+ use = egg:oslo.middleware#cors
allowed_origin=https://website.example.com:443,https://website2.example.com:443
max_age=3600
allow_methods=GET,POST,PUT,DELETE
@@ -74,7 +74,7 @@ existing configuration from oslo_config in order to simplify the points of
configuration, this may be done as follows.::
[filter:cors]
- paste.filter_factory = oslo_middleware.cors:filter_factory
+ use = egg:oslo.middleware#cors
oslo_config_project = oslo_project_name
# Optional field, in case the program name is different from the project:
diff --git a/doc/source/oslo_config.rst b/doc/source/oslo_config.rst
index 6e772c6..e6134a5 100644
--- a/doc/source/oslo_config.rst
+++ b/doc/source/oslo_config.rst
@@ -23,7 +23,7 @@ Configuration with paste-deploy and the oslo.config
The paste filter (in /etc/my_app/api-paste.ini) will looks like::
[filter:sizelimit]
- paste.filter_factory = oslo_middleware.sizelimit:RequestBodySizeLimiter.factory
+ use = egg:oslo.middleware#sizelimit
# In case of the application doesn't use the global oslo.config
# object. The middleware must known the app name to load
# the application configuration, by setting this:
@@ -45,7 +45,7 @@ Configuration with pastedeploy only
The paste filter (in /etc/my_app/api-paste.ini) will looks like::
[filter:sizelimit]
- paste.filter_factory = oslo_middleware.sizelimit:RequestBodySizeLimiter.factory
+ use = egg:oslo.middleware#sizelimit
max_request_body_size=1000
This will override any configuration done via oslo.config
diff --git a/oslo_middleware/healthcheck/__init__.py b/oslo_middleware/healthcheck/__init__.py
index 81aed9e..c85e1ac 100644
--- a/oslo_middleware/healthcheck/__init__.py
+++ b/oslo_middleware/healthcheck/__init__.py
@@ -21,6 +21,7 @@ import socket
import sys
import traceback
+from debtcollector import removals
import jinja2
from oslo_utils import reflection
from oslo_utils import strutils
@@ -51,11 +52,10 @@ def _expand_template(contents, params):
class Healthcheck(base.ConfigurableMiddleware):
- """Healthcheck middleware used for monitoring.
+ """Healthcheck application used for monitoring.
- If the path is ``/healthcheck``, it will respond 200 with "OK" as
- the body. Or a 503 with the reason as the body if one of the backends
- reports an application issue.
+ It will respond 200 with "OK" as the body. Or a 503 with the reason as the
+ body if one of the backends reports an application issue.
This is useful for the following reasons:
@@ -239,9 +239,8 @@ class Healthcheck(base.ConfigurableMiddleware):
.. code-block:: ini
- [filter:healthcheck]
- paste.filter_factory = oslo_middleware:Healthcheck.factory
- path = /healthcheck
+ [app:healthcheck]
+ use = egg:oslo.middleware:healthcheck
backends = disable_by_file
disable_by_file_path = /var/run/nova/healthcheck_disable
@@ -253,21 +252,29 @@ class Healthcheck(base.ConfigurableMiddleware):
.. code-block:: ini
- [pipeline:public_api]
- pipeline = healthcheck_public sizelimit [...] public_service
+ [composite:public_api]
+ use = egg:Paste#urlmap
+ / = public_api_pipeline
+ /healthcheck = healthcheck_public
+
+ [composite:admin_api]
+ use = egg:Paste#urlmap
+ / = admin_api_pipeline
+ /healthcheck = healthcheck_admin
- [pipeline:admin_api]
- pipeline = healthcheck_admin sizelimit [...] admin_service
+ [pipeline:public_api_pipeline]
+ pipeline = sizelimit [...] public_service
- [filter:healthcheck_public]
- paste.filter_factory = oslo_middleware:Healthcheck.factory
- path = /healthcheck_public
+ [pipeline:admin_api_pipeline]
+ pipeline = sizelimit [...] admin_service
+
+ [app:healthcheck_public]
+ use = egg:oslo.middleware:healthcheck
backends = disable_by_file
disable_by_file_path = /var/run/nova/healthcheck_public_disable
[filter:healthcheck_admin]
- paste.filter_factory = oslo_middleware:Healthcheck.factory
- path = /healthcheck_admin
+ use = egg:oslo.middleware:healthcheck
backends = disable_by_file
disable_by_file_path = /var/run/nova/healthcheck_admin_disable
"""
@@ -393,10 +400,35 @@ Reason
# always return text/plain (because sending an error from this
# middleware actually can cause issues).
self._default_accept = 'text/plain'
+ self._ignore_path = False
def _conf_get(self, key, group='healthcheck'):
return super(Healthcheck, self)._conf_get(key, group=group)
+ @removals.remove(
+ message="The healthcheck middleware must now be configured as "
+ "an application, not as a filter")
+ @classmethod
+ def factory(cls, global_conf, **local_conf):
+ return super(Healthcheck, cls).factory(global_conf, **local_conf)
+
+ @classmethod
+ def app_factory(cls, global_conf, **local_conf):
+ """Factory method for paste.deploy.
+
+ :param global_conf: dict of options for all middlewares
+ (usually the [DEFAULT] section of the paste deploy
+ configuration file)
+ :param local_conf: options dedicated to this middleware
+ (usually the option defined in the middleware
+ section of the paste deploy configuration file)
+ """
+ conf = global_conf.copy() if global_conf else {}
+ conf.update(local_conf)
+ o = cls(application=None, conf=conf)
+ o._ignore_path = True
+ return o
+
@staticmethod
def _get_threadstacks():
threadstacks = []
@@ -510,7 +542,7 @@ Reason
@webob.dec.wsgify
def process_request(self, req):
- if req.path != self._path:
+ if not self._ignore_path and req.path != self._path:
return None
results = [ext.obj.healthcheck(req.server_port)
for ext in self._backends]
diff --git a/oslo_middleware/healthcheck/opts.py b/oslo_middleware/healthcheck/opts.py
index d283f4d..ff39e98 100644
--- a/oslo_middleware/healthcheck/opts.py
+++ b/oslo_middleware/healthcheck/opts.py
@@ -16,6 +16,7 @@ from oslo_config import cfg
HEALTHCHECK_OPTS = [
cfg.StrOpt('path',
default='/healthcheck',
+ deprecated_for_removal=True,
help='The path to respond to healtcheck requests on.'),
cfg.BoolOpt('detailed',
default=False,
diff --git a/setup.cfg b/setup.cfg
index 116d465..357a1a6 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -36,6 +36,9 @@ oslo.middleware.healthcheck =
disable_by_file = oslo_middleware.healthcheck.disable_by_file:DisableByFileHealthcheck
disable_by_files_ports = oslo_middleware.healthcheck.disable_by_file:DisableByFilesPortsHealthcheck
+paste.app_factory =
+ healthcheck = oslo_middleware:Healthcheck.app_factory
+
paste.filter_factory =
catch_errors = oslo_middleware:CatchErrors.factory
correlation_id = oslo_middleware:CorrelationId.factory