Merge "Add optional healthcheck middleware"
This commit is contained in:
commit
5ff2d13975
ironic_inspector
releasenotes/notes
tools
@ -19,6 +19,7 @@ from ironic_inspector.conf import default
|
|||||||
from ironic_inspector.conf import discovery
|
from ironic_inspector.conf import discovery
|
||||||
from ironic_inspector.conf import dnsmasq_pxe_filter
|
from ironic_inspector.conf import dnsmasq_pxe_filter
|
||||||
from ironic_inspector.conf import extra_hardware
|
from ironic_inspector.conf import extra_hardware
|
||||||
|
from ironic_inspector.conf import healthcheck
|
||||||
from ironic_inspector.conf import iptables
|
from ironic_inspector.conf import iptables
|
||||||
from ironic_inspector.conf import ironic
|
from ironic_inspector.conf import ironic
|
||||||
from ironic_inspector.conf import pci_devices
|
from ironic_inspector.conf import pci_devices
|
||||||
@ -39,6 +40,7 @@ discovery.register_opts(CONF)
|
|||||||
default.register_opts(CONF)
|
default.register_opts(CONF)
|
||||||
dnsmasq_pxe_filter.register_opts(CONF)
|
dnsmasq_pxe_filter.register_opts(CONF)
|
||||||
extra_hardware.register_opts(CONF)
|
extra_hardware.register_opts(CONF)
|
||||||
|
healthcheck.register_opts(CONF)
|
||||||
iptables.register_opts(CONF)
|
iptables.register_opts(CONF)
|
||||||
ironic.register_opts(CONF)
|
ironic.register_opts(CONF)
|
||||||
pci_devices.register_opts(CONF)
|
pci_devices.register_opts(CONF)
|
||||||
|
33
ironic_inspector/conf/healthcheck.py
Normal file
33
ironic_inspector/conf/healthcheck.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
from ironic_inspector.common.i18n import _
|
||||||
|
|
||||||
|
_OPTS = [
|
||||||
|
cfg.BoolOpt('enabled',
|
||||||
|
default=False,
|
||||||
|
help=_('Enable the health check endpoint at /healthcheck. '
|
||||||
|
'Note that this is unauthenticated. More information '
|
||||||
|
'is available at '
|
||||||
|
'https://docs.openstack.org/oslo.middleware/latest/'
|
||||||
|
'reference/healthcheck_plugins.html.')),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def register_opts(conf):
|
||||||
|
conf.register_opts(_OPTS, group='healthcheck')
|
||||||
|
|
||||||
|
|
||||||
|
def list_opts():
|
||||||
|
return _OPTS
|
@ -69,6 +69,7 @@ def list_opts():
|
|||||||
('dnsmasq_pxe_filter',
|
('dnsmasq_pxe_filter',
|
||||||
ironic_inspector.conf.dnsmasq_pxe_filter.list_opts()),
|
ironic_inspector.conf.dnsmasq_pxe_filter.list_opts()),
|
||||||
('extra_hardware', ironic_inspector.conf.extra_hardware.list_opts()),
|
('extra_hardware', ironic_inspector.conf.extra_hardware.list_opts()),
|
||||||
|
('healthcheck', ironic_inspector.conf.healthcheck.list_opts()),
|
||||||
('ironic', ironic_inspector.conf.ironic.list_opts()),
|
('ironic', ironic_inspector.conf.ironic.list_opts()),
|
||||||
('iptables', ironic_inspector.conf.iptables.list_opts()),
|
('iptables', ironic_inspector.conf.iptables.list_opts()),
|
||||||
('port_physnet', ironic_inspector.conf.port_physnet.list_opts()),
|
('port_physnet', ironic_inspector.conf.port_physnet.list_opts()),
|
||||||
|
@ -70,6 +70,8 @@ def _init_middleware():
|
|||||||
else:
|
else:
|
||||||
LOG.warning('Starting unauthenticated, please check'
|
LOG.warning('Starting unauthenticated, please check'
|
||||||
' configuration')
|
' configuration')
|
||||||
|
if CONF.healthcheck.enabled:
|
||||||
|
utils.add_healthcheck_middleware(_app)
|
||||||
utils.add_cors_middleware(_app)
|
utils.add_cors_middleware(_app)
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ from openstack.baremetal.v1 import node
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_middleware import cors as cors_middleware
|
from oslo_middleware import cors as cors_middleware
|
||||||
|
from oslo_middleware import healthcheck as healthcheck_middleware
|
||||||
import pytz
|
import pytz
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
@ -246,6 +247,14 @@ def add_cors_middleware(app):
|
|||||||
app.wsgi_app = cors_middleware.CORS(app.wsgi_app, CONF)
|
app.wsgi_app = cors_middleware.CORS(app.wsgi_app, CONF)
|
||||||
|
|
||||||
|
|
||||||
|
def add_healthcheck_middleware(app):
|
||||||
|
"""Add healthcheck middleware
|
||||||
|
|
||||||
|
:param app: application
|
||||||
|
"""
|
||||||
|
app.wsgi_app = healthcheck_middleware.Healthcheck(app.wsgi_app, CONF)
|
||||||
|
|
||||||
|
|
||||||
def check_auth(request, rule=None, target=None):
|
def check_auth(request, rule=None, target=None):
|
||||||
"""Check authentication on request.
|
"""Check authentication on request.
|
||||||
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The new ``[healthcheck] enabled`` option has been added. When this option
|
||||||
|
is set to ``True``, the healthcheck middleware is enabled in API pipeline
|
||||||
|
and the additional API endpoint to monitor service availability becomes
|
||||||
|
available at ``/healthcheck`` path.
|
@ -7,6 +7,7 @@ namespace = oslo.db
|
|||||||
namespace = oslo.log
|
namespace = oslo.log
|
||||||
namespace = oslo.messaging
|
namespace = oslo.messaging
|
||||||
namespace = oslo.middleware.cors
|
namespace = oslo.middleware.cors
|
||||||
|
namespace = oslo.middleware.healthcheck
|
||||||
namespace = oslo.policy
|
namespace = oslo.policy
|
||||||
namespace = oslo.service.service
|
namespace = oslo.service.service
|
||||||
namespace = oslo.service.sslutils
|
namespace = oslo.service.sslutils
|
||||||
|
Loading…
x
Reference in New Issue
Block a user