Add a /healthcheck middleware
By default, cinder-api isn't providing a /healthcheck URL, which is super useful for setting-up monitoring and HAProxy. This patch adds it by default. Change-Id: I03a93bf14a5ba159b68bfba15a7f4f26c8200e36
This commit is contained in:
parent
07a4dd548c
commit
696ef12f4e
33
cinder/tests/functional/test_middleware.py
Normal file
33
cinder/tests/functional/test_middleware.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# Copyright 2020 Thomas Goirand <zigo@debian.org>
|
||||||
|
# Copyright 2020 Infomaniak Networks.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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_serialization import jsonutils
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from cinder.tests.functional import functional_helpers
|
||||||
|
|
||||||
|
|
||||||
|
class TestHealthCheckMiddleware(functional_helpers._FunctionalTestBase):
|
||||||
|
|
||||||
|
def test_healthcheck(self):
|
||||||
|
# We verify that we return a HTTP200 when calling api_get
|
||||||
|
url = 'http://%s:%s/healthcheck' % (self.osapi.host, self.osapi.port)
|
||||||
|
response = requests.request(
|
||||||
|
'GET',
|
||||||
|
url,
|
||||||
|
headers={'Accept': 'application/json'})
|
||||||
|
output = jsonutils.loads(response.content)
|
||||||
|
self.assertEqual(['OK'], output['reasons'])
|
@ -5,6 +5,7 @@
|
|||||||
[composite:osapi_volume]
|
[composite:osapi_volume]
|
||||||
use = call:cinder.api:root_app_factory
|
use = call:cinder.api:root_app_factory
|
||||||
/: apiversions
|
/: apiversions
|
||||||
|
/healthcheck: healthcheck
|
||||||
/v2: openstack_volume_api_v2
|
/v2: openstack_volume_api_v2
|
||||||
/v3: openstack_volume_api_v3
|
/v3: openstack_volume_api_v3
|
||||||
|
|
||||||
@ -63,3 +64,8 @@ paste.filter_factory = cinder.api.middleware.auth:CinderKeystoneContext.factory
|
|||||||
|
|
||||||
[filter:authtoken]
|
[filter:authtoken]
|
||||||
paste.filter_factory = keystonemiddleware.auth_token:filter_factory
|
paste.filter_factory = keystonemiddleware.auth_token:filter_factory
|
||||||
|
|
||||||
|
[app:healthcheck]
|
||||||
|
paste.app_factory = oslo_middleware:Healthcheck.app_factory
|
||||||
|
backends = disable_by_file
|
||||||
|
disable_by_file_path = /etc/cinder/healthcheck_disable
|
||||||
|
7
releasenotes/notes/healthcheck-449ed4292e6bfa22.yaml
Normal file
7
releasenotes/notes/healthcheck-449ed4292e6bfa22.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The oslo.middleware /healthcheck is now activated by default in the Cinder
|
||||||
|
api-paste.ini. Operators can use it to configure HAproxy or the monitoring
|
||||||
|
of Cinder APIs. Edit the ``api-paste.ini`` file and remove any healthcheck
|
||||||
|
entries to disable this functionality.
|
Loading…
x
Reference in New Issue
Block a user