summaryrefslogtreecommitdiff
path: root/oslo_middleware
diff options
context:
space:
mode:
authorMehdi Abaakouk <mehdi.abaakouk@enovance.com>2015-01-26 12:51:37 +0100
committerMehdi Abaakouk <mehdi.abaakouk@enovance.com>2015-01-26 14:25:27 +0100
commit3687523a653e66d811e50fac858527fe4cf4601a (patch)
tree7382202fc9d34e9a94a30c9d909f61af6742d6ec /oslo_middleware
parentd345a4b6a2ab63603caabaea6260351d86591165 (diff)
downloadoslo-middleware-3687523a653e66d811e50fac858527fe4cf4601a.tar.gz
Fixes the healthcheck factory method and docs0.4.0
This change fix the factory method of the healthcheck middleware It also adds documentation about how to configure the middleware Change-Id: Ie549d4686e921a9d407ba2829f69f92216bfcf9a
Diffstat (limited to 'oslo_middleware')
-rw-r--r--oslo_middleware/healthcheck/__init__.py50
-rw-r--r--oslo_middleware/healthcheck/disable_by_file.py16
2 files changed, 62 insertions, 4 deletions
diff --git a/oslo_middleware/healthcheck/__init__.py b/oslo_middleware/healthcheck/__init__.py
index 559770a..39291f6 100644
--- a/oslo_middleware/healthcheck/__init__.py
+++ b/oslo_middleware/healthcheck/__init__.py
@@ -22,10 +22,52 @@ from oslo_middleware import base
class Healthcheck(base.Middleware):
- """Helper class that returns debug information.
+ """Healthcheck middleware used for monitoring.
+
+ If the path is /healthcheck, it will respond 200 with "OK" as the body.
+ Or 503 with the reason as the body if one of the backend report
+ an application issue.
+
+ Example of paste configuration:
+
+ .. code-block:: ini
+
+ [filter:healthcheck]
+ paste.filter_factory = oslo_middleware:Healthcheck.factory
+ path = /healthcheck
+ backends = disable_by_file
+ disable_by_file_path = /var/run/nova/healthcheck_disable
+
+ [pipeline:public_api]
+ pipeline = healthcheck sizelimit [...] public_service
+
+
+ Multiple filter sections can be defined if it desired to have
+ pipelines with different healthcheck configuration, example:
+
+ .. code-block:: ini
+
+ [pipeline:public_api]
+ pipeline = healthcheck_public sizelimit [...] public_service
+
+ [pipeline:admin_api]
+ pipeline = healthcheck_admin sizelimit [...] admin_service
+
+ [filter:healthcheck_public]
+ paste.filter_factory = oslo_middleware:Healthcheck.factory
+ path = /healthcheck_public
+ 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
+ backends = disable_by_file
+ disable_by_file_path = /var/run/nova/healthcheck_admin_disable
+
+ More details on available backends and their configuration can be found
+ on this page: :doc:`healthcheck_plugins`.
- Can be inserted into any WSGI application chain to get information about
- the request and response.
"""
NAMESPACE = "oslo.middleware.healthcheck"
@@ -38,7 +80,7 @@ class Healthcheck(base.Middleware):
def healthcheck_filter(app):
return cls(app, conf)
- return cls
+ return healthcheck_filter
def __init__(self, application, conf):
super(Healthcheck, self).__init__(application)
diff --git a/oslo_middleware/healthcheck/disable_by_file.py b/oslo_middleware/healthcheck/disable_by_file.py
index 05d61bf..61a55c8 100644
--- a/oslo_middleware/healthcheck/disable_by_file.py
+++ b/oslo_middleware/healthcheck/disable_by_file.py
@@ -23,6 +23,22 @@ LOG = logging.getLogger(__name__)
class DisableByFileHealthcheck(pluginbase.HealthcheckBaseExtension):
+ """DisableByFile healthcheck middleware plugin
+
+ This plugin checks presence of a file to report if the service
+ is unavailable or not.
+
+ Example of middleware configuration:
+
+ .. code-block:: ini
+
+ [filter:healthcheck]
+ paste.filter_factory = oslo_middleware:Healthcheck.factory
+ path = /healthcheck
+ backends = disable_by_file
+ disable_by_file_path = /var/run/nova/healthcheck_disable
+ """
+
def healthcheck(self):
path = self.conf.get('disable_by_file_path')
if path is None: